public void AddParcel_ValidInputArguments_ReturnsParcelTrackingNumber() { //Arrange var mockMapper = new Mock <AutoMapper.IMapper>(); mockMapper.Setup(m => m.Map <Entities.Parcel>(It.IsAny <IO.Swagger.Models.Parcel>())).Returns(validBLParcel); mockMapper.Setup(m => m.Map <DataAccess.Entities.Parcel>(It.IsAny <Entities.Parcel>())).Returns(validDALParcel); mockMapper.Setup(m => m.Map <Entities.Parcel>(It.IsAny <DataAccess.Entities.Parcel>())).Returns(validBLParcel); mockMapper.Setup(m => m.Map <IO.Swagger.Models.Parcel>(It.IsAny <Entities.Parcel>())).Returns(validSwagParcel); mockMapper.Setup(m => m.Map <Entities.Recipient>(It.IsAny <DataAccess.Entities.Recipient>())).Returns(validBLRec); mockMapper.Setup(m => m.Map <ServiceAgents.DTOs.Recipient>(It.IsAny <Entities.Recipient>())).Returns(validSARecipient); mockMapper.Setup(m => m.Map <Entities.Location>(It.IsAny <ServiceAgents.DTOs.Location>())).Returns(validBLLocation); var mapper = mockMapper.Object; encodingAgent = new GoogleEncodingAgent(googleEncodingAgentLogger); Interfaces.IParcelEntryLogic parcelLogic = new ParcelEntryLogic(mockWarehouseRepo, mockTruckRepo, mockParcelRepo, mockTrackRepo, mockHopRepo, encodingAgent, parcelEntryLogicLogger, mapper); //Act var trackNumber = parcelLogic.AddParcel(validSwagParcel); //Assert Assert.IsNotNull(trackNumber); Assert.AreEqual(trackNumber.Length, 8); }
public void AddParcel_InvalidParcel_ThrowsException() { var mockMapper = new Mock <AutoMapper.IMapper>(); mockMapper.Setup(m => m.Map <Entities.Parcel>(It.IsAny <IO.Swagger.Models.Parcel>())).Returns(invalidBLParcel); mockMapper.Setup(m => m.Map <DataAccess.Entities.Parcel>(It.IsAny <Entities.Parcel>())).Returns(validDALParcel); var mapper = mockMapper.Object; encodingAgent = new GoogleEncodingAgent(googleEncodingAgentLogger); Interfaces.IParcelEntryLogic parcelLogic = new ParcelEntryLogic(mockWarehouseRepo, mockTruckRepo, mockParcelRepo, mockTrackRepo, mockHopRepo, encodingAgent, parcelEntryLogicLogger, mapper); Assert.ThrowsException <BlException>(() => parcelLogic.AddParcel(validSwagParcel)); }