Skip to content

Instantly share code, notes, and snippets.

View Msirkovsky's full-sized avatar

Marek Sirkovský Msirkovsky

View GitHub Profile
@Msirkovsky
Msirkovsky / DeleteUserCommandHandlerTests,cs
Created March 17, 2024 05:33
Tabnine - DeleteUserCommandHandlerTests
public class DeleteUserCommandHandlerTests
{
private readonly AssistantsAIDbContext _context;
private readonly DeleteUserCommandHandler _handler;
public DeleteUserCommandHandlerTests()
{
var options = new DbContextOptionsBuilder<AssistantsAIDbContext>()
.UseInMemoryDatabase(databaseName: "AssistantsAITest")
@Msirkovsky
Msirkovsky / DeleteUserCommandHandlerTests.cs
Created March 16, 2024 17:10
JetBrains AI - DeleteUserCommandHandlerTests
namespace AssistantsAI.Commands;
public class DeleteUserCommandHandlerTests
{
[Fact]
public async Task Should_Delete_User_If_Exists_And_NotLocked()
{
// Arrange
var mockContext = new Mock<MyDbContext>();
var mockDbSet = new Mock<DbSet<User>>();
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace SourceGeneratorsExample;
[Generator(LanguageNames.CSharp)]
public class SourceGeneratorWithInterceptors : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context)
// On the server side:
function ServerComponent(){
return <div>I am a server component</div>
}
<ClientComponent>
<ServerComponent></ServerComponent>
</ClientComponent>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Calendar ID="Calendar1" ShowTitle="True" OnSelectionChanged="Calendar1_SelectionChanged"
runat="server" />
<div> Background: <br />
<asp:DropDownList ID="ColorList" AutoPostBack="True" OnSelectedIndexChanged="DropDownSelection_Change"
runat="server">
<asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
<asp:ListItem Value="Silver"> Silver </asp:ListItem>
const [lat, long] = getCoordinates()
vs.
const [long, lat] = getCoordinates()
//How do you know which one is correct? Even typescript doesn't help you here.
// Better version with a record:
const {lat,long} = getCoordinates()
const memoized = new Map()
function compute(... args) {
const key = #[...args] // magic is here
if (memoized.has(key))
{
return memoized.get(key)
}
else {
const value = carrySlowComputation(...args)
const memoized = new Map()
function compute(... args) {
const key = JSON.stringify({...args})
if (memoized.has(key))
{
return memoized.get(key)
}
else {
const value = carrySlowComputation(...args)
// [count, setCount] is a classic tuple but now without the support of a native tuple.
const [count, setCount] = useState(0)
const record = #{ name: "S. Holmes", age: 27 }
const record2 = Record.fromEntries([["age", 27], #["name", "S. Holmes"]]) // Note that any iterable of entries will work
const tuple = Tuple(...[1, 2, 3])
const tuple2 = Tuple.from([1, 2, 3]) // Note that an iterable will work as well
record == #{ name: "S. Holmes", age: 27 } => true
tuple == #[1, 2, 3]) => true
// JS Compiler throws an error when using a non-primitive value