示例#1
0
        public async void TestGetByIdAsync()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "SchemaDatabase")
                          .Options;

            var dbContext = new ApplicationDbContext(options);
            var repo      = new SchemaRepository(dbContext);
            var json      = "{id: 123}";
            // Act
            var newSchema = await repo.CreateAsync(new Schema { SavedDate = DateTime.Now, SchemaJson = json });

            var createdId = newSchema.Id;

            var searchResult = await repo.GetByIdAsync(createdId);

            // Assert
            Assert.True(createdId > 0 && searchResult.SchemaJson == json);
        }