public void TestGetAllPcParts() { // Arrange var repo = new PcPartRepository(_context, _mapper); // act var result = repo.GetAll(); // assert Assert.Equal(34, result.Count()); }
public async Task TestPcPartsGetById() { // arrange var repo = new PcPartRepository(_context, _mapper); // act var result = await repo.GetById(1); // assert Assert.Equal(MockData.StandardPcPart.Name, result.Name); }
public async void TestPcPartForListBasic() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected // act var result = await repo.GetPartsBasic(); // assert Assert.Equal(MockData.ListOfPcParts.Count(), result.Count()); }
public async void TestPcPartUpdatePcPart() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected var expectedPartName = MockData.StandardPcPart.Name; // act var result = await repo.Update(await repo.GetById(1)); // assert Assert.Equal(expectedPartName, result.Name); }
public async void TestPcPartForBasicPart() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected string expectedPartName = MockData.StandardPcPart.Name; // act var result = await repo.GetPartsBasicById(1); // assert Assert.Equal(expectedPartName, result.Name); }
public void TestPcPartRepoForImageByName() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected var image = MockData.ListOfImages.Where(i => i.FileName == "amd_ryzen_5.jpg").FirstOrDefault(); // act var result = repo.GetImagePathByName("amd_ryzen_5.jpg"); // assert Assert.Equal(image.Id, result.Id); }
public async Task TestPcPartRepoGetPartByPcPartId() { // arrange var repo = new PcPartRepository(_context, _mapper); int partIndex = 5; var expected = MockData.Cpus.Where(c => c.Id == 2).FirstOrDefault(); // 2 is the cpu with partId 5 // act var result = await repo.GetPartById(partIndex); // assert Assert.Equal(expected.PcPartId, result.PcPartId); }
public async Task TestGetAllByCategoryNamePCpartsRepo() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected var parts = repo.db.PcParts.Where(p => p.Type == PartType.Gpu).ToList(); // act var result = await repo.GetAllByCategoryName("Gpu"); // assert Assert.Equal(parts, result); }
public async void TestPcPartControllerGetPartByPcPartId() { // arrange var repo = new PcPartRepository(_context, _mapper); var controller = new PcPartsController(repo); // act var result = await controller.PartByPartId(4); // assert var objectResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(StatusCodes.Status200OK, objectResult.StatusCode); }
public void TestPcPartControllerGetCategories() { // arrange var repo = new PcPartRepository(_context, _mapper); var controller = new PcPartsController(repo); // act var result = controller.Categories(); // assert var objectResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(StatusCodes.Status200OK, objectResult.StatusCode); }
public async void TestPcPartAddPcPart() { // arrange var repo = new PcPartRepository(_context, _mapper); // expected var PartToAdd = await repo.GetById(1); PartToAdd.Name = "GeForce GTX 2090 Ti"; // act var result = await repo.Add(PartToAdd); // assert Assert.Equal(PartToAdd.Name, result.Name); }
public async void TestPcPartControllerImageByFileName() { // arrange var repo = new PcPartRepository(_context, _mapper); var controller = new PcPartsController(repo); var contentType = "image/jpeg"; // act var result = controller.ImageByFileName("amd_ryzen_5.jpg"); // assert var objectResult = Assert.IsType <PhysicalFileResult>(result); Assert.Equal(contentType, objectResult.ContentType); }