public void DeleteNotFound()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);

            Func <Task> delete = async() =>
            {
                await repository.Delete(default(int));
            };

            delete.Should().NotThrow();
        }
Beispiel #2
0
        public async void Delete()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository          = new TestAllFieldTypeRepository(loggerMoc.Object, context);
            TestAllFieldType entity = new TestAllFieldType();

            context.Set <TestAllFieldType>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            TestAllFieldType modifiedRecord = await context.Set <TestAllFieldType>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
        public async void DeleteFound()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository          = new TestAllFieldTypeRepository(loggerMoc.Object, context);
            TestAllFieldType entity = new TestAllFieldType();

            entity.SetProperties(default(int), 2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
            context.Set <TestAllFieldType>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            var records = await context.Set <TestAllFieldType>().ToListAsync();

            records.Count.Should().Be(1);
        }