public void WhenShopByNameDoesntExistThenEmptyShopIsReturned() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopByName("shopName")).Returns((Shop)null); var shopRepositoryService = new ShopRepositoryService(shopRepository.Object, Mock.Of <IUserRepository>()); ShopDto shop = shopRepositoryService.GetShopByName("shopName"); shop.ShouldBeEquivalentTo(ShopDto.EmptyShop); }
public void WhenRequestedShopExistThenReturnThatShop() { var shopRepositoryService = new ShopRepositoryService(Mock.Of <IShopRepository>(r => r.GetShopByName("shopName") == new Shop() { Name = "shopName" }), Mock.Of <IUserRepository>()); ShopDto shop = shopRepositoryService.GetShopByName("shopName"); shop.Should().NotBeNull(); shop.Name.Should().Be("shopName"); }
public void WhenShopNameIsNullOrEmptyThenThrowArgumentNullException(string shopName) { var shopRepositoryService = new ShopRepositoryService(Mock.Of <IShopRepository>(), Mock.Of <IUserRepository>()); Assert.Throws <ArgumentNullException>(() => shopRepositoryService.GetShopByName(shopName)); }