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 ShouldCalculateIfAllInstancesHaveBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

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

             var allPurchased = sut.IsAllPurchased();

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

            var sut = new SinglePurchase1
                          {
                              StoreGateway = mockGateway
                          };

            var result = sut.IsPurchased;

            Assert.True(mockGateway.IsPurchasedWasCalledWith("SinglePurchase1"));
            Assert.True(result);
        }
        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 ShouldUseCustomFormatterIfSetInDerivedToggle()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

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

             var confuguredFormatter = sut.NameInstanceFormatter;

             Assert.IsType(typeof(RepeatPurchaseToggleNameInstanceFormatterMoqaLate), confuguredFormatter);
        }
        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);
        }