public void DeleteRepair_WhenRepairIsFound_RemovesRepair()
        {
            var vehicleId = 1;
            var repair    = new Repair
            {
                Description = "Wash",
                Details     = "Washed and waxed car",
                Cost        = 5,
                VehicleId   = vehicleId,
                RepairDate  = DateTime.Today
            };

            var result   = _repairService.SaveRepair(repair);
            var orgCount = _repairService.GetAllByVehicleId(vehicleId).Count();

            _repairService.DeleteRepair(result.Id);
            Assert.NotEqual(orgCount, _repairService.GetAllByVehicleId(vehicleId).Count());
        }
Exemplo n.º 2
0
        public void Delete_Repair()
        {
            var repairContextMock = new Mock <DB.Interface.IDatabaseService>();

            repairContextMock.Setup(x => x.Repairs).Returns(repairsMock.Object);
            repairContextMock.Setup(x => x.Cars).Returns(carsMock.Object);
            repairContextMock.Setup(x => x.RepairNotes).Returns(repairNotesMock.Object);

            var repairService = new RepairService(repairContextMock.Object);

            repairService.DeleteRepair(new BL.Repair.DTO.RepairDTO
            {
                Id    = 1,
                CarId = 2,
                Date  = DateTime.Parse("10.08.2018 15:53:00"),
                Name  = "Olejek",
                updatedRepairNoteId = 1,
                Notes = new List <RepairNoteDTO> {
                    new RepairNoteDTO {
                        Id = 1, Description = "Uzyto oleju 5W40 Valvoline"
                    }
                }
            });
            try
            {
                // repairNotesMock.Verify(m => m.Add(It.IsAny<RepairNotes>()), Times.AtLeastOnce);
                repairContextMock.Verify(m => m.Save(), Times.AtLeastOnce());
                var IsInactiveRepair = repairContextMock.Object.Repairs.Where(x => x.RepairID == 1).FirstOrDefault().IsInactive;

                var IsInactiveRepairNote = repairContextMock.Object.RepairNotes.Where(x => x.RepairNotesID == 1).FirstOrDefault().IsInactive;
                Assert.IsTrue(IsInactiveRepair == "Y");
                Assert.IsTrue(IsInactiveRepairNote == "Y");
                Assert.IsTrue(true);
            }
            catch (Exception e)
            {
                Assert.IsTrue(false);
            }
        }