public void ReturnFalse_When_Courier_IsNotFound_InDatabase() { // Arrange string fakeFirstName = "testFirstName"; string fakeLastName = "testLastName"; var fakeCouriers = new List <Courier>() { }.GetQueryableMockDbSet(); var ctxStub = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); ctxStub .Setup(ctx => ctx.Couriers) .Returns(fakeCouriers.Object); // Act var result = courierService.CourierExistsByName(fakeFirstName, fakeLastName); // Assert Assert.AreEqual(false, result); }
public void Throw_ArgumentNullException_When_FirstNameOrLastName_IsNullOrEmpty() { // Arrange string fakeFirstName = null; string fakeLastName = "testLastName"; var ctxStub = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); Action executingCourierExistsByNameMethod = () => courierService.CourierExistsByName(fakeFirstName, fakeLastName); // Act & Assert Assert.ThrowsException <ArgumentNullException>(executingCourierExistsByNameMethod); }