public void GenerateRequestForReportFbaFeePreviewReport_WithCanadianMarketplaceAndCustomTrue_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Canada);

            var propertiesContainer = _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces, custom: true);

            Assert.NotNull(propertiesContainer);
        }
        AllListingsReport_WithValidMarketplacesAndCustomTrueProvided_ReturnsContainerWithReportOptionsPropertyContains_CustomArgumentSerializedWithValueTrue()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Canada);

            var propertiesContainer = _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces, custom: true);

            Assert.AreEqual("custom=true;", propertiesContainer.ReportOptions);
        }
        public void GenerateRequestForReportFbaFeePreviewReport_WithNonUsOrEuMarketplacesProvided_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Japan);

            var propertiesContainer = _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces);

            Assert.NotNull(propertiesContainer);
        }
        public void FbaFeePreviewReport_WithNonUsOrEUMarketplaceProvided_ThrowsArgumentException()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Japan);

            _fbaReportsFactory = new FbaReportsFactory();

            Assert.Throws <ArgumentException>(() => _fbaReportsFactory.FbaFeePreviewReport(DateTime.UtcNow, requestedMarketplaces: marketplaceGroup.GetMarketplaces));
        }
        public void TryAddMarketplace_WithInitialEndpointOfUS_CanAddMexicoMarketplaceId_ToInternalMarketplaceIdList()
        {
            var MwsMarketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.US);

            MwsMarketplaceGroup.TryAddMarketplace(MwsMarketplace.Mexico);

            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.US.Id);
            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.Mexico.Id);
        }
        public void TryAddMarketplace_TryingToAddAMarketplaceToTheSameGroupTwice_ThrowsInvalidOperationException()
        {
            var MwsMarketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.France);

            MwsMarketplaceGroup.TryAddMarketplace(MwsMarketplace.Germany);

            Assert.Throws <InvalidOperationException>(() =>
                                                      MwsMarketplaceGroup.TryAddMarketplace(MwsMarketplace.Germany));
        }
        public void TryAddMarketplace_WithInitialEndpointOfUK_CanAddEuropeanMarketplaceId_ToInternalMarketplaceIdList()
        {
            var MwsMarketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.UK);

            MwsMarketplaceGroup.TryAddMarketplace(MwsMarketplace.Germany);

            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.UK.Id);
            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.Germany.Id);
        }
        public void AddMarketplace_TryingToAddAMarketplaceToTheSameGroupTwice_ThrowsInvalidOperationException()
        {
            var reportRequestedMarketplacesGroup = new MwsMarketplaceGroup(MwsMarketplace.Germany);

            Assert.Throws <InvalidOperationException>(() =>
                                                      reportRequestedMarketplacesGroup
                                                      .AddMarketplace(MwsMarketplace.France)
                                                      .AddMarketplace(MwsMarketplace.France));
        }
        public void AddMarketplace_WithValidMarketplace_AddsMarketplaceIdToInternalMarketplaceIdList()
        {
            var reportRequestedMarketplacesGroup = new MwsMarketplaceGroup(MwsMarketplace.Germany)
                                                   .AddMarketplace(MwsMarketplace.France);

            CollectionAssert.Contains(reportRequestedMarketplacesGroup.GetMarketplacesIdList, MwsMarketplace.Germany.Id);
            CollectionAssert.Contains(reportRequestedMarketplacesGroup.GetMarketplacesIdList, MwsMarketplace.France.Id);
            Assert.AreEqual(2, reportRequestedMarketplacesGroup.GetMarketplacesIdList.Count());
        }
        public void GenerateRequestForReportFbaFeePreviewReport_WithNorthAmericanMarketplacesProvided_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.US)
                                   .AddMarketplace(MwsMarketplace.Canada)
                                   .AddMarketplace(MwsMarketplace.Mexico);

            var propertiesContainer = _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces);

            Assert.NotNull(propertiesContainer);
        }
        public void TryAddMarketplace_WithValidMarketplace_AddsMarketplaceIdToInternalMarketplaceIdList()
        {
            var MwsMarketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Canada);

            MwsMarketplaceGroup.TryAddMarketplace(MwsMarketplace.US);

            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.Canada.Id);
            CollectionAssert.Contains(MwsMarketplaceGroup.GetMarketplacesIdList, MwsMarketplace.US.Id);
            Assert.AreEqual(2, MwsMarketplaceGroup.GetMarketplacesIdList.Count());
        }
Beispiel #12
0
        public void FirstOrDefault_TwoInQueue_ReturnsFirstObjectPopulatedWithCorrectData()
        {
            var feedSubmissionEntry = _feedSubmissionEntryService.FirstOrDefault();
            var feedSubmissionData  = JsonConvert.DeserializeObject <FeedSubmissionPropertiesContainer>(feedSubmissionEntry.FeedSubmissionData);

            Assert.AreEqual(AmazonRegion.Europe, feedSubmissionEntry.AmazonRegion);
            Assert.AreEqual("TargetHandlerId", feedSubmissionEntry.TargetHandlerId);
            Assert.AreEqual("{\"key1\":\"value1\"}", feedSubmissionEntry.TargetHandlerArgs);
            Assert.AreEqual("testFeedType", feedSubmissionEntry.FeedType);
            CollectionAssert.AreEquivalent(new List <string>(MwsMarketplaceGroup.AmazonEurope().Select(m => m.Id)), feedSubmissionData.MarketplaceIdList);
        }
        public void FbaFeePreviewReport_WithNorthAmericanMarketplacesProvided_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.US)
                                   .AddMarketplace(MwsMarketplace.Canada)
                                   .AddMarketplace(MwsMarketplace.Mexico);

            _fbaReportsFactory = new FbaReportsFactory();

            var reportRequest = _fbaReportsFactory.FbaFeePreviewReport(DateTime.UtcNow, requestedMarketplaces: marketplaceGroup.GetMarketplaces);

            Assert.NotNull(reportRequest);
        }
Beispiel #14
0
        public void FirstOrDefault_TwoInQueue_ReturnsFirstObjectContainingCorrectData()
        {
            var reportRequestCallback = _reportRequestEntryService.FirstOrDefault();
            var reportRequestData = JsonConvert.DeserializeObject<ReportRequestPropertiesContainer>(reportRequestCallback.ReportRequestData);

            Assert.AreEqual(AmazonRegion.Europe, reportRequestCallback.AmazonRegion);
            Assert.AreEqual("TargetHandlerId", reportRequestCallback.TargetHandlerId);
            Assert.AreEqual("{\"key1\":\"value1\",\"key2\":\"value2\"}", reportRequestCallback.TargetHandlerArgs);
            Assert.AreEqual("_Report_Type_", reportRequestCallback.ReportType);
            Assert.AreEqual(ContentUpdateFrequency.NearRealTime, reportRequestData.UpdateFrequency);
            CollectionAssert.AreEquivalent(new List<string>(MwsMarketplaceGroup.AmazonEurope().Select(m => m.Id)), reportRequestData.MarketplaceIdList);
        }
        public void GenerateRequestForReportFbaFeePreviewReport_WithEuropeanMarketplacesProvided_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.UK)
                                   .AddMarketplace(MwsMarketplace.Germany)
                                   .AddMarketplace(MwsMarketplace.France)
                                   .AddMarketplace(MwsMarketplace.Italy)
                                   .AddMarketplace(MwsMarketplace.Spain);

            var propertiesContainer = _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces);

            Assert.NotNull(propertiesContainer);
        }
Beispiel #16
0
        public ReportRequestPropertiesContainer FbaFeePreviewReport(DateTime startDate,
                                                                    DateTime?endDate, IEnumerable <MwsMarketplace> requestedMarketplaces = null)
        {
            var permittedMarketplacesIds = new List <MwsMarketplace> {
                MwsMarketplace.US, MwsMarketplace.Canada, MwsMarketplace.Mexico
            };

            permittedMarketplacesIds.AddRange(MwsMarketplaceGroup.AmazonEurope());
            return(ReportGeneratorHelper.GenerateReportRequest("_GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA_",
                                                               ContentUpdateFrequency.AtLeast72Hours,
                                                               requestedMarketplaces: requestedMarketplaces,
                                                               startDate: startDate, endDate: endDate ?? DateTime.UtcNow));
        }
        public void FbaFeePreviewReport_WithEuropeanMarketplacesProvided_ReturnsRequest()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.UK)
                                   .AddMarketplace(MwsMarketplace.Germany)
                                   .AddMarketplace(MwsMarketplace.France)
                                   .AddMarketplace(MwsMarketplace.Italy)
                                   .AddMarketplace(MwsMarketplace.Spain);

            _fbaReportsFactory = new FbaReportsFactory();

            var reportRequest = _fbaReportsFactory.FbaFeePreviewReport(DateTime.UtcNow, requestedMarketplaces: marketplaceGroup.GetMarketplaces);

            Assert.NotNull(reportRequest);
        }
        public void GenerateRequestForReportFbaFeePreviewReport_WithNorthAmericanMarketplaceNonUSOrCAAndCustomTrue_ThrowsArgumentException()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Mexico);

            Assert.Throws <ArgumentException>(() => _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces, custom: true));
        }
        [TestCase("A39IBJ37TRP1C6")]            // Australia marketplace id
        public void AmazonOther_Returns_ListContainingExpectedMarketplaceID(string marketplaceId)
        {
            var amazonGlobalMarketplaceIds = MwsMarketplaceGroup.AmazonOther().Select(m => m.Id);

            CollectionAssert.Contains(amazonGlobalMarketplaceIds, marketplaceId);
        }
Beispiel #20
0
        public void SetUp()
        {
            var reportRequestPropertiesContainer = new ReportRequestPropertiesContainer("_Report_Type_", ContentUpdateFrequency.NearRealTime, new List<string>(MwsMarketplaceGroup.AmazonEurope().Select(m => m.Id)));

            _reportRequestEntries = new List<ReportRequestEntry>
            {
                new ReportRequestEntry
                {
                    AmazonRegion = AmazonRegion.Europe,
                    ReportRequestData = JsonConvert.SerializeObject(reportRequestPropertiesContainer),
                    LastAmazonRequestDate = DateTime.MinValue,
                    ContentUpdateFrequency = 0,
                    Id = 1,
                    ReportType = reportRequestPropertiesContainer.ReportType,
                    TargetHandlerId = "TargetHandlerId",
                    TargetHandlerArgs = JsonConvert.SerializeObject(new Dictionary<string, object>{ { "key1", "value1"}, { "key2", "value2"} })
                },
                new ReportRequestEntry{Id = 2}
            };

			_loggerMock = new Mock<IEasyMwsLogger>();
			_reportRequestCallbackReportMock = new Mock<IReportRequestEntryRepository>();
            _reportRequestCallbackReportMock.Setup(x => x.GetAll()).Returns(_reportRequestEntries.AsQueryable());
            _reportRequestEntryService = new ReportRequestEntryService(_reportRequestCallbackReportMock.Object, _options, _loggerMock.Object);
        }
        [TestCase("APJ6JRA9NG5V4")]             // Italy marketplace id
        public void AmazonOther_Returns_ListNotContainingExpectedMarketplaceID(string marketplaceId)
        {
            var amazonGlobalMarketplaceIds = MwsMarketplaceGroup.AmazonOther();

            CollectionAssert.DoesNotContain(amazonGlobalMarketplaceIds, marketplaceId);
        }
Beispiel #22
0
        private static void ValidateMarketplaceCompatibility(string reportType, IEnumerable <string> requestedMarketplacesIds = null)
        {
            if (requestedMarketplacesIds == null)
            {
                return;
            }

            var permittedMarketplacesIds = ReportsPermittedMarketplacesMapper.GetMarketplaces(reportType)?.Select(m => m.Id) ?? MwsMarketplaceGroup.AmazonGlobal().Select(m => m.Id);

            foreach (var requestedMarketplace in requestedMarketplacesIds)
            {
                if (!permittedMarketplacesIds.Contains(requestedMarketplace))
                {
                    throw new ArgumentException(
                              $@"The report request for type:'{reportType}', is only available to the following marketplaces:'{
								MwsMarketplace.GetMarketplaceCountryCodesAsCommaSeparatedString(permittedMarketplacesIds)
							}'.
The requested marketplace:'{
								MwsMarketplace.GetMarketplaceCountryCode(requestedMarketplace)
							}' is not supported by Amazon MWS for the specified report type"                            );
                }
            }
        }
Beispiel #23
0
        public void Setup()
        {
            _options = new EasyMwsOptions();
            var propertiesContainer = new FeedSubmissionPropertiesContainer("testFeedContent", "testFeedType", false,
                                                                            new List <string>(MwsMarketplaceGroup.AmazonEurope().Select(m => m.Id)));
            var serializedPropertiesContainer = JsonConvert.SerializeObject(propertiesContainer);

            _feedSubmissionEntries = new List <FeedSubmissionEntry>
            {
                new FeedSubmissionEntry(serializedPropertiesContainer)
                {
                    Id = 2
                },
                new FeedSubmissionEntry(serializedPropertiesContainer)
                {
                    Id                = 1,
                    AmazonRegion      = AmazonRegion.Europe,
                    TargetHandlerId   = "TargetHandlerId",
                    TargetHandlerArgs = JsonConvert.SerializeObject(new Dictionary <string, object> {
                        { "key1", "value1" }
                    }),
                    FeedType           = propertiesContainer.FeedType,
                    FeedSubmissionData = JsonConvert.SerializeObject(propertiesContainer)
                }
            };

            _loggerMock = new Mock <IEasyMwsLogger>();
            _feedSubmissionCallbackRepoMock = new Mock <IFeedSubmissionEntryRepository>();
            _feedSubmissionCallbackRepoMock.Setup(x => x.GetAll()).Returns(_feedSubmissionEntries.AsQueryable());
            _feedSubmissionEntryService = new FeedSubmissionEntryService(_feedSubmissionCallbackRepoMock.Object, _options, _loggerMock.Object);
        }
        public void GenerateRequestForReportFbaFeePreviewReport_WithInternationalMarketplaceNonIndiaAndCustomTrue_ThrowsArgumentException()
        {
            var marketplaceGroup = new MwsMarketplaceGroup(MwsMarketplace.Japan);

            Assert.Throws <ArgumentException>(() => _inventoryReportsFactory.AllListingsReport(requestedMarketplaces: marketplaceGroup.GetMarketplaces, custom: true));
        }