public void ShouldCallNopServiceUsingTwoLetterIsoLanguageName() { // arrange var request = new SynchronizeProductRequest("1001") { Language = "uk-UA" }; // act this.processor.Process(new ServicePipelineArgs(request, new ServiceProviderResult())); // assert this.client.Received().GetProduct("1001", "uk"); }
/// <summary> /// Initializes a new instance of the <see cref="SaveProductToExternalCommerceSystemTest" /> class. /// </summary> public SaveProductToExternalCommerceSystemTest() { this.client = Substitute.For <IProductsServiceChannel>(); var clientFactory = Substitute.For <ServiceClientFactory>(); clientFactory.CreateClient <IProductsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client); this.processor = new SaveProductToExternalCommerceSystem { ClientFactory = clientFactory }; this.product = new Product { ExternalId = "100500", Name = "Cool car", ShortDescription = "Yea, dude. You wants this one", FullDescription = "Don't think, just pay for this" }; this.language = "en"; this.request = new SynchronizeProductRequest("100500") { Language = this.language }; this.result = new ServiceProviderResult(); this.args = new ServicePipelineArgs(this.request, this.result); this.args.Request.Properties["Product"] = this.product; }
/// <summary> /// Initializes a new instance of the <see cref="ReadExternalCommerceSystemProductTest" /> class. /// </summary> // TODO:[Minor] Test initialization is too complex and it is not required for all the tests in the class. This lead to unclear test behaviour. public ReadExternalCommerceSystemProductTest() { this.entityFactory = Substitute.For <IEntityFactory>(); this.entityFactory.Create("Product").Returns(callInfo => new Product()); this.entityFactory.Create("ClassificationGroup").Returns(callInfo => new ClassificationGroup()); this.entityFactory.Create("Classification").Returns(callInfo => new Classification()); this.entityFactory.Create("Specification").Returns(callInfo => new Specification()); this.entityFactory.Create("ProductType").Returns(callInfo => new ProductType()); this.client = Substitute.For <IProductsServiceChannel>(); var clientFactory = Substitute.For <ServiceClientFactory>(); clientFactory.CreateClient <IProductsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client); this.productClassificationGroupName = "Categories"; this.productClassificationGroupExternalId = "0"; this.processor = new ReadExternalCommerceSystemProduct(this.productClassificationGroupName, this.productClassificationGroupExternalId) { EntityFactory = this.entityFactory, ClientFactory = clientFactory }; this.product = new Product { ExternalId = "100500" }; this.language = "en"; this.request = new SynchronizeProductRequest("100500") { Language = this.language }; this.result = new ServiceProviderResult(); this.args = new ServicePipelineArgs(this.request, this.result); this.created = DateTime.Now; this.updated = DateTime.Now; this.productModel = new ProductModel { ProductId = "100500", ProductVariantId = "100500", Name = "Cool car", ShortDescription = "Yea, dude. You wants this one", FullDescription = "Don't think, just pay for this", ManufacturerIds = new[] { "The best company in the world" }, CreatedOnUtc = this.created, UpdatedOnUtc = this.updated, CategoryIds = new[] { "Cars", "Luxury" }, Sku = "sku", ProductGlobalSpecifications = new[] { new ProductGlobalSpecificationModel { SpecificationLookupId = "157", LookupValueId = "157_300", SpecificationLookupName = "hard drive", LookupValueName = "xxx" }, new ProductGlobalSpecificationModel { SpecificationLookupId = "200", LookupValueId = "200_400", SpecificationLookupName = "memory", LookupValueName = "yyy" } } }; }