public async Task TestAddFolderTaskAsync_validParentFolder() { // Arrange var dbContext = AppDBContextMocker.GetAppDbContext(nameof(TestAddFolderTaskAsync_validParentFolder)); var fService = new FolderService(new FolderRepository(dbContext), new UnitOfWork(dbContext), null); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ResourceToModelProfile()); cfg.AddProfile(new ModelToResourceProfile()); }); var folderModel = new SaveFolderResource() { Name = "validParentFolder", ParentFolderId = 104, }; // Act var controller = new FoldersController(fService, mockMapper.CreateMapper(), null); var response = await controller.AddFolderAsync(folderModel) as ObjectResult; dbContext.Dispose(); // Assert Assert.NotNull(response); var folderResponce = response.Value as FolderResource; Assert.NotNull(folderResponce); Assert.NotNull(folderResponce.FolderID); Assert.Equal(folderResponce.Name, folderModel.Name); Assert.Null(folderModel.ParentFolderId); }
public async Task TestDeleteTestCaseFilesAsync_Valid() { // Arrange var dbContext = AppDBContextMocker.GetAppDbContext(nameof(TestListTestCaseFilesAsync)); var tcService = new TestCaseService(new TestCaseRepository(dbContext), new UnitOfWork(dbContext), null); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ResourceToModelProfile()); cfg.AddProfile(new ModelToResourceProfile()); }); var controller = new TestCaseFilesController(tcService, mockMapper.CreateMapper(), null); // Act var response = await controller.DeleteTestCaseFileAsync(101) as ObjectResult; dbContext.Dispose(); // Assert Assert.NotNull(response); var deletedModel = response.Value as TestCaseResource; Assert.NotNull(deletedModel); Assert.Equal("Email.txt", deletedModel.Name); Assert.Equal(3, deletedModel.Type); Assert.Equal(2, deletedModel.StepCount); Assert.Null(deletedModel.FolderId); }
public async Task TestAddTestCaseFilesAsync_InvalidType() { // Arrange var dbContext = AppDBContextMocker.GetAppDbContext(nameof(TestAddTestCaseFilesAsync_InvalidType)); var tcService = new TestCaseService(new TestCaseRepository(dbContext), new UnitOfWork(dbContext), null); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ResourceToModelProfile()); cfg.AddProfile(new ModelToResourceProfile()); }); var testModel = new SaveTestCaseResource() { Name = "Mad Max: Fury Road", Type = 10, //Type doesn't exist StepCount = 2, FolderId = 100, }; // Act var controller = new TestCaseFilesController(tcService, mockMapper.CreateMapper(), null); var response = await controller.AddTestCaserAsync(testModel) as ObjectResult; dbContext.Dispose(); // Assert Assert.NotNull(response); var rModel = response.Value as TestCaseResource; Assert.Null(rModel); }
public async Task TestListTestCaseFilesAsync_NotFound() { // Arrange var dbContext = AppDBContextMocker.GetAppDbContext(nameof(TestListTestCaseFilesAsync)); var tcService = new TestCaseService(new TestCaseRepository(dbContext), new UnitOfWork(dbContext), null); //auto mapper configuration var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new ResourceToModelProfile()); cfg.AddProfile(new ModelToResourceProfile()); }); // Act var controller = new TestCaseFilesController(tcService, mockMapper.CreateMapper(), null); var response = await controller.ListAsync(100) as IEnumerable <TestCaseResource>; dbContext.Dispose(); Assert.NotNull(response); Assert.Empty(response); }