public async Task AddEmployeeAsyncTest_WithCoreectData_ShouldReturnTrue() { var context = SteuDbContextInMemoryFactory.InitializeContext(); MapperInitializer.InitializeMapper(); var repository = new EfDeletableEntityRepository <SteuUser>(context); var service = new EmployeesService(repository, this.GetMockUserManager().Object); await repository.AddAsync(new SteuUser() { Id = "asdasd", UserName = "******", Company = new Company() { Name = "Pesho Ltd", }, }); await repository.SaveChangesAsync(); AddEmployeeInputModel model = new AddEmployeeInputModel() { FirstName = "Gosho", LastName = "Goshov", Username = "******", Email = "*****@*****.**", Password = "******", ConfirmPassword = "******", }; var actualResult = await service.AddEmployeeAsync("asdasd", model); Assert.True(actualResult); }
public async Task AddEmployeeAsyncTest_WithIncorrectUserId_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); MapperInitializer.InitializeMapper(); var repository = new EfDeletableEntityRepository <SteuUser>(context); var service = new EmployeesService(repository, this.GetMockUserManager().Object); await repository.AddAsync(new SteuUser() { Id = "asdasd", UserName = "******", Company = new Company() { Name = "Pesho Ltd", }, }); await repository.SaveChangesAsync(); AddEmployeeInputModel model = new AddEmployeeInputModel() { FirstName = "Gosho", LastName = "Goshov", Username = "******", Email = "*****@*****.**", Password = "******", ConfirmPassword = "******", }; await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddEmployeeAsync("asd", model)); }
public async Task GetCountOfLoadsAsync_WithOutData_ShouldReturnZero() { var context = SteuDbContextInMemoryFactory.InitializeContext(); LoadsService service = IntializeLoadService(context); var actualResult = await service.GetCountOfLoadsAsync(); Assert.Equal(0, actualResult); }
public async Task GetAllAvaibleLoadsAsync_WithoutData_ShouldReturnEmptyList() { var context = SteuDbContextInMemoryFactory.InitializeContext(); LoadsService service = IntializeLoadService(context); var actualResult = await service.GetAllAvaibleLoadsAsync(1, 10); Assert.Empty(actualResult); }
public async Task AddNewsAsync_WithNullUserId_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); NewsService service = this.IntializeNewsService(context); var repository = new EfDeletableEntityRepository <News>(context); await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddNewsAsync("title", "content", null, null)); }
public async Task GetOrderDetailsForNewMessageAsync_WithInvalidOrderId_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); MessagesService service = this.IntializeMessagesService(context); var repository = new EfDeletableEntityRepository <Message>(context); await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetOrderDetailsForNewMessageAsync <SendMessageInputModel>("or")); }
public async Task AddActionToLog_WithNullAction_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeLogsService(context); var repository = new EfDeletableEntityRepository <Log>(context); Assert.Throws <ArgumentNullException>(() => service.AddActionToLog("Pesho", null)); }
public async Task GetAllLogsAsync_WithEmptyArray_ReturtListOfLogs() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeLogsService(context); var repository = new EfDeletableEntityRepository <Log>(context); var actualResult = await service.GetAllLogsAsync(1, 10); Assert.Empty(actualResult); }
public async Task GetOrCreateTownByName_WithData_ShouldReturnTown() { var context = SteuDbContextInMemoryFactory.InitializeContext(); TownsService service = this.IntializeTownsService(context); var repository = new EfRepository <Town>(context); var actualResult = service.GetOrCreateTownByName("Sofia"); Assert.Equal("Sofia", actualResult.Name); }
public async Task GetAllNewsAsync_WithOutData_ShouldReturnListOFNews() { var context = SteuDbContextInMemoryFactory.InitializeContext(); NewsService service = this.IntializeNewsService(context); var repository = new EfDeletableEntityRepository <News>(context); var actualResult = await service.GetAllNewsAsync(1, 10, null); Assert.Empty(actualResult); }
public async Task GetAllTruckTypesAsyncTest_WithOutData_RreturnEmptyListOfTruckTypes() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var actualResult = await service.GetAllTruckTypesAsync <AllTruckTypesTruckEditViewModel>(); Assert.Empty(actualResult); }
public async Task GetOrderDetailsForNewMessageAsync_WithCorrectData_ReturnModel() { var context = SteuDbContextInMemoryFactory.InitializeContext(); MessagesService service = this.IntializeMessagesService(context); var repository = new EfDeletableEntityRepository <Message>(context); var actualResult = await service.GetOrderDetailsForNewMessageAsync <SendMessageInputModel>("orderId"); Assert.Equal("Bulgaria", actualResult.CountryFrom); }
public async Task AddNewsAsync_WithCorrectAndNullPicture_ShouldAddNewsToRepository() { var context = SteuDbContextInMemoryFactory.InitializeContext(); NewsService service = this.IntializeNewsService(context); var repository = new EfDeletableEntityRepository <News>(context); await service.AddNewsAsync("title", "content", null, "userId"); var actualResult = await repository.All().ToListAsync(); Assert.Single(actualResult); }
public async Task GetCountryByNameTest_WithNull_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); await this.SeedData(context); MapperInitializer.InitializeMapper(); var repository = new EfRepository <Country>(context); var service = new CountriesService(repository); Assert.Throws <ArgumentNullException>(() => service.GetCountryByName(null)); }
public async Task AddNewsAsync_WithCorrectData_ShouldAddNewsToRepository() { var context = SteuDbContextInMemoryFactory.InitializeContext(); NewsService service = this.IntializeNewsService(context); var repository = new EfDeletableEntityRepository <News>(context); IFormFile file = new FormFile(new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, "Data", "dummy.txt"); await service.AddNewsAsync("title", "content", file, "userId"); var actualResult = await repository.All().ToListAsync(); Assert.Single(actualResult); }
public async Task GetAllCountriesAsyncTest_Correct_ShouldReturnAllCountries() { var context = SteuDbContextInMemoryFactory.InitializeContext(); await this.SeedData(context); MapperInitializer.InitializeMapper(); var repository = new EfRepository <Country>(context); var service = new CountriesService(repository); var actualResult = await service.GetAllCountriesAsync <AllCountiresEditLoadViewModel>(); Assert.Equal(3, actualResult.Count); }
public async Task GetCountryByNameTest_WhtiCorrectData_ShouldRetunCountry() { var context = SteuDbContextInMemoryFactory.InitializeContext(); await this.SeedData(context); MapperInitializer.InitializeMapper(); var repository = new EfRepository <Country>(context); var service = new CountriesService(repository); var actualResult = service.GetCountryByName("Bulgaria"); Assert.Equal("Bulgaria", actualResult.Name); }
public async Task AddActionToLog_WithCorrectData_ReturnTrue() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeLogsService(context); var repository = new EfDeletableEntityRepository <Log>(context); var actualResult = service.AddActionToLog("Pesho", "/"); Assert.True(actualResult); var actualArray = await repository.All().ToListAsync(); Assert.Single(actualArray); }
public async Task GetAddressOrCreateByCoutryNameAndTownName_WithNullTownTest_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); await this.SeedData(context); MapperInitializer.InitializeMapper(); var repository = new EfDeletableEntityRepository <Address>(context); var countryService = new Mock <ICountriesService>(); var townService = new Mock <ITownsService>(); var service = new AddressesService(repository, countryService.Object, townService.Object); Assert.Throws <ArgumentNullException>(() => service.GetAddressOrCreateByCoutryNameAndTownName("Bulgaria", null)); }
public async Task DeleteLoadByIdAsyncTest_WithIncorrectData_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); LoadsService service = IntializeLoadService(context); var repository = new EfDeletableEntityRepository <Order>(context); var order = new Order() { Id = "asdasd", }; await repository.AddAsync(order); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.DeleteLoadByIdAsync("asd")); }
public async Task DeleteMessageByUserIdAsync_WithNullUserId_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeDeleteMessagesService(context); var repository = new EfDeletableEntityRepository <Message>(context); Message message = new Message() { Content = "content", SenderId = "userId", }; await repository.AddAsync(message); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.DeleteMessageByUserIdAsync(null)); }
public async Task GetPriorityTypeByNameAsync_WithInvalidPriorityTypeName_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializePriorityTypesService(context); var repository = new EfRepository <PriorityType>(context); var priority = new PriorityType() { Name = "Normal", }; await repository.AddAsync(priority); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetPriorityTypeByNameAsync("asd")); }
public async Task GetOrderByIdAsync_WithNullOrderId_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeOrdersService(context); var repository = new EfDeletableEntityRepository <Order>(context); var order = new Order() { Id = "orderId", }; await repository.AddAsync(order); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetOrderByIdAsync <SendMessageInputModel>(null)); }
public async Task DeleteUserCompanyByCompanyIdAsyncTest_WithInCorrectData_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); await context.Companies.AddAsync(new Company() { Id = "asdasd", Name = "Test Ltd", }); await context.SaveChangesAsync(); MapperInitializer.InitializeMapper(); var repository = new EfDeletableEntityRepository <Company>(context); var service = new CompaniesService(repository); await Assert.ThrowsAsync <ArgumentNullException>(() => service.DeleteUserCompanyByCompanyIdAsync("Test")); }
public async Task GetTruckTypeByNameAsync_WithNullTypeName_ShouldRetyrnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var truckType = new TruckType() { Name = "Normal", }; await repository.AddAsync(truckType); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetTruckTypeByNameAsync(null)); }
public async Task AddUserLikeModeratorAsync_WithNullUserId_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeUsersService(context); var repository = new EfDeletableEntityRepository <SteuUser>(context); var user = new SteuUser() { Id = "userId", }; await repository.AddAsync(user); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddUserLikeModeratorAsync(null)); }
public async Task CreateCompanyAsyncTest_WhitNullUser_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); MapperInitializer.InitializeMapper(); var repository = new EfDeletableEntityRepository <Company>(context); var service = new CompaniesService(repository); var model = new CreateCompanyBindingModel() { Name = "Test Ltd", UIC = "123123123", UserId = "asdasd asd asd asd ", LicenseUrl = "dadadasdadasd", }; await Assert.ThrowsAsync <ArgumentNullException>(() => service.CreateCompanyAsync(model, null)); }
public async Task AddUserLikeModeratorAsync_WithCorrectData_ShouldReturnTrue() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeUsersService(context); var repository = new EfDeletableEntityRepository <SteuUser>(context); var user = new SteuUser() { Id = "userId", }; await repository.AddAsync(user); await repository.SaveChangesAsync(); var actualResult = await service.AddUserLikeModeratorAsync("userId"); Assert.True(actualResult); }
public async Task ChangeUserIsAuthorizeSatusByUserIdAsync_WithNullStatus_ShouldReturnArgumentNullException() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeUsersService(context); var repository = new EfDeletableEntityRepository <SteuUser>(context); var user = new SteuUser() { Id = "userId", IsAuthorize = false, }; await repository.AddAsync(user); await repository.SaveChangesAsync(); await Assert.ThrowsAsync <ArgumentNullException>(() => service.ChangeUserIsAuthorizeSatusByUserIdAsync("userId", null)); }
public async Task GetTruckTypeByNameAsync_WithValidTruckTypeName_RreturnTruckType() { var context = SteuDbContextInMemoryFactory.InitializeContext(); var service = this.IntializeTruckTypesService(context); var repository = new EfRepository <TruckType>(context); var truckType = new TruckType() { Name = "Normal", }; await repository.AddAsync(truckType); await repository.SaveChangesAsync(); var actualResult = await service.GetTruckTypeByNameAsync("Normal"); Assert.Equal("Normal", actualResult.Name); }