public void ShouldCalculateIfAllInstancesHaveBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway
             };

             var allPurchased = sut.IsAllPurchased();

             Assert.True(allPurchased);
        }
        public void ShouldCallGatewayAsManyTimesAsThereAreOfferNumbersWhenCalculatingTotalPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
            mockGateway.IsPurchasedSetReturnValue(true);

            var sut = new RepeatPurchaseWith123Instances()
                          {
                              StoreGateway = mockGateway
                          };

            sut.GetTotalPurchased();

            Assert.Equal(123, mockGateway.IsPurchasedTimesCalled());
        }
        public void ShouldCalculateNextLowestUnPurchased()
        {
            var mockGateway = new StoreGatewayHandMock
             {
                 DefaultIsPurchasedValue = true,
                 OddOneOutInAppOfferNameToReturnNotDefaultValue =
                     "RepeatPurchaseWith123Instances_99"
             };

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway
             };

             var nextUnpurchasedInstance = sut.GetNextLowestUnpurchasedInstance();

             Assert.Equal(99, nextUnpurchasedInstance);
        }
        public void ShouldCalculateIfAllInstancesHaveNotBeenPurchased()
        {
            var mockGateway = new StoreGatewayHandMock
                                   {
                                       DefaultIsPurchasedValue = true,
                                       OddOneOutInAppOfferNameToReturnNotDefaultValue =
                                           "RepeatPurchaseWith123Instances_99"
                                   };

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway
             };

             var allPurchased = sut.IsAllPurchased();

             Assert.False(allPurchased);
        }
        public void ShouldCallNameFormatterAsManyTimesAsThereAreOfferNumbersWhenCalculatingTotalPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

             var mockConcat = new  RepeatPurchaseToggleNameInstanceFormatterMoqaLate();

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway,
                 NameInstanceFormatter = mockConcat
             };

             sut.GetTotalPurchased();

             Assert.Equal(123, mockConcat.FormatTimesCalled());
        }
        public void ShouldReturnTotalOffersAvailable()
        {
            var sut = new RepeatPurchaseWith123Instances();

            var totalOffers = sut.AvailableStoreInstances;

            Assert.Equal(123, totalOffers);
        }
        public void ShouldReturnIfSpecificInstanceHasBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway
             };

             var isPurchased = sut.IsInstancePurchased(123);

             Assert.True(isPurchased);

             // TODO: this should prob be in sep test
             // Due to current limitations with MoqaLate, we can only get what the last call was for a particular method
             mockGateway.IsPurchasedWasCalledWith("MultiFeatureWith123Instances_123");

             // test the negative version
             mockGateway.IsPurchasedSetReturnValue(false);

             isPurchased = sut.IsInstancePurchased(123);

             Assert.False(isPurchased);

             // TODO: this should prob be in sep test
             // Due to current limitations with MoqaLate, we can only get what the last call was for a particular method
             mockGateway.IsPurchasedWasCalledWith("RepeatPurchaseWith123Instances_123");
        }
        public void ShouldGracefullyHandleNextLowestUnPurchasedWhenAllHaveBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

             var sut = new RepeatPurchaseWith123Instances()
             {
                 StoreGateway = mockGateway
             };

             var nextUnpurchasedInstance = sut.GetNextLowestUnpurchasedInstance();

             Assert.Equal(-1, nextUnpurchasedInstance);
        }
        public void ShouldDefaultToUnderscoreIntanceNumberFormatter()
        {
            var sut = new RepeatPurchaseWith123Instances();

            Assert.IsType(typeof(NameUnderscoreNumberFormatter), sut.NameInstanceFormatter);
        }
        public void ShouldDefaultToRealWindowsStoreGateway()
        {
            var sut = new RepeatPurchaseWith123Instances();

            Assert.IsType(typeof (RealStoreGateway), sut.StoreGateway);
        }