コード例 #1
0
        public void ShouldCallGatewayAsManyTimesAsThereAreOfferNumbersWhenCalculatingTotalPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
            mockGateway.IsPurchasedSetReturnValue(true);

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

            sut.GetTotalPurchased();

            Assert.Equal(123, mockGateway.IsPurchasedTimesCalled());
        }
コード例 #2
0
        public void ShouldCalculateIfAllInstancesHaveBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

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

             var allPurchased = sut.IsAllPurchased();

             Assert.True(allPurchased);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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");
        }
コード例 #7
0
        public void ShouldGracefullyHandleNextLowestUnPurchasedWhenAllHaveBeenPurchased()
        {
            var mockGateway = new StoreGatewayMoqaLate();
             mockGateway.IsPurchasedSetReturnValue(true);

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

             var nextUnpurchasedInstance = sut.GetNextLowestUnpurchasedInstance();

             Assert.Equal(-1, nextUnpurchasedInstance);
        }