Beispiel #1
0
        public async void All()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
Beispiel #2
0
        public void DeleteNotFound()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);

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

            delete.Should().NotThrow();
        }
        public async void Create()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);

            var entity = new TestAllFieldTypesNullable();
            await repository.Create(entity);

            var record = await context.Set <TestAllFieldTypesNullable>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Beispiel #4
0
        public async void Create()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);

            var entity = new TestAllFieldTypesNullable();

            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");
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
        public async void Get()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);

            TestAllFieldTypesNullable entity = new TestAllFieldTypesNullable();

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

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
        public async void Delete()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
            TestAllFieldTypesNullable entity = new TestAllFieldTypesNullable();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TestAllFieldTypesNullableRepository> > loggerMoc = TestAllFieldTypesNullableRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypesNullableRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypesNullableRepository(loggerMoc.Object, context);
            TestAllFieldTypesNullable entity = new TestAllFieldTypesNullable();

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

            await repository.Update(new TestAllFieldTypesNullable());

            var modifiedRecord = context.Set <TestAllFieldTypesNullable>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }