public void GetLatestProductUpdatesForVendorTestNoUpdates() { _productUpdateMoq.Stub(x => x.GetMessage()).Return(null).Repeat.Once(); IEnumerable<VendorProduct> results = null; var testService = new ProductUpdateService(_vendorMoq, _productUpdateMoq); Assert.DoesNotThrow(() => results = testService.GetLatestProductUpdatesForVendor("TRK")); Assert.That(results, Is.Not.Null); Assert.That(results.Count(), Is.EqualTo(0)); }
public void GetLatestProductUpdatesForVendorTestSingleUpdate() { var moqProduct = MockRepository.GenerateStub<VendorProduct>(); _productUpdateMoq.Stub(x => x.GetMessage()).Return(new CloudQueueMessage("{Updates:[{VendorCode:\"TRK\", ProductId: \"Test\"},{VendorCode:\"TTT\", ProductId: \"Test2\"}]}")).Repeat.Once(); _vendorMoq.Stub(x => x.GetUpdatedVendorProduct(Arg<ProductUpdate>.Matches(pu => pu.VendorCode == "TRK" && pu.ProductId == "Test"))).Return(moqProduct).Repeat.Once(); IEnumerable<VendorProduct> results = null; var testService = new ProductUpdateService(_vendorMoq, _productUpdateMoq); Assert.DoesNotThrow(() => results = testService.GetLatestProductUpdatesForVendor("TRK")); Assert.That(results, Is.Not.Null); Assert.That(results.Count(), Is.EqualTo(1)); Assert.That(results.First(), Is.EqualTo(moqProduct)); }