コード例 #1
0
        public async void All()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public async void Create()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
コード例 #4
0
        public async void Create()
        {
            Mock <ILogger <TestAllFieldTypeRepository> > loggerMoc = TestAllFieldTypeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TestAllFieldTypeRepositoryMoc.GetContext();
            var repository = new TestAllFieldTypeRepository(loggerMoc.Object, context);

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

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

            records.Count.Should().Be(2);
        }
コード例 #5
0
        public async void Get()
        {
            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();

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

            record.Should().NotBeNull();
        }
コード例 #6
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();
        }
コード例 #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            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.Update(new TestAllFieldType());

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

            modifiedRecord.Should().NotBeNull();
        }