Ejemplo n.º 1
0
        public async Task UpdateAsyncCorrectlyUpdatesInformation()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.FileExtensions.AddRangeAsync(this.SeedData());

            await context.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <FileExtension>(context);

            var service = new FileExtensionsService(repository);

            var model = new EditViewModel
            {
                Name      = "NewName",
                FileType  = "File",
                IsDeleted = true,
            };

            var result = await service.UpdateAsync(1, model);

            Assert.NotEqual(-1, result);

            var dbRecord = await context.FileExtensions.FindAsync(1);

            Assert.NotEqual("First", dbRecord.Name);
            Assert.NotNull(dbRecord.DeletedOn);
            Assert.True(dbRecord.IsDeleted);
        }
Ejemplo n.º 2
0
        public async Task UpdateAsyncFailsWhenIdNotInDb()
        {
            AutoMapperInitializer.InitializeMapper();
            var context    = InMemoryDbContextInitializer.InitializeContext();
            var repository = new EfDeletableEntityRepository <FileExtension>(context);

            var service = new FileExtensionsService(repository);

            var model = new EditViewModel
            {
                Name      = "NewName",
                IsDeleted = true,
            };

            var result = await service.UpdateAsync(100, model);

            Assert.Equal(-1, result);
        }