public void WhenShopRepositoryReturnNullThenEmptyCollectionIsReturned() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetAllShops()).Returns((IEnumerable <Shop>)null); var shopService = new ShopRepositoryService(shopRepository.Object, Mock.Of <IUserRepository>()); IEnumerable <ShopDto> shops = shopService.GetAllShops(); shops.Should().BeEmpty(); }
public void WhenShopByUniqueIdIsNullTheReturnEmptyShop() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetShopById(It.IsAny <Guid>())).Returns((Shop)null); var shopRepositoryService = new ShopRepositoryService(shopRepository.Object, Mock.Of <IUserRepository>()); ShopDto shop = shopRepositoryService.GetShopByUniqueId(It.IsAny <Guid>()); shop.ShouldBeEquivalentTo(ShopDto.EmptyShop); }
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 WhenShopWithSpecifiedUniqueIdExistThenReturnThatShop() { Guid shopGuid = Guid.NewGuid(); var shopRepositoryService = new ShopRepositoryService(Mock.Of <IShopRepository>(r => r.GetShopById(shopGuid) == new Shop() { UniqueId = shopGuid }), Mock.Of <IUserRepository>()); ShopDto shop = shopRepositoryService.GetShopByUniqueId(shopGuid); shop.Should().NotBeNull(); shop.ShopGuid.Should().Be(shopGuid); }
public void WhenShopRepositoryReturnSomeRecordsThenAllRecordsAreMappedIntoShopDto() { var shopRepository = new Mock <IShopRepository>(); shopRepository.Setup(r => r.GetAllShops()).Returns(new List <Shop>() { Mock.Of <Shop>(), Mock.Of <Shop>() }); var shopService = new ShopRepositoryService(shopRepository.Object, Mock.Of <IUserRepository>()); IEnumerable <ShopDto> shops = shopService.GetAllShops(); shops.Should().NotBeEmpty(); shops.Should().HaveCount(2); }
public void WhenShopNameIsNullOrEmptyThenThrowArgumentNullException(string shopName) { var shopRepositoryService = new ShopRepositoryService(Mock.Of <IShopRepository>(), Mock.Of <IUserRepository>()); Assert.Throws <ArgumentNullException>(() => shopRepositoryService.GetShopByName(shopName)); }