Beispiel #1
0
        public static TipInfo GetNewTip()
        {
            TipInfo nextTip = _tipCalculator.GetNextTip();

            if (nextTip == null)
            {
                // No new tips to show. Attempt to reset history and start again.
                nextTip = GetTipAfterResetTipHistory(ref nextTip);
            }

            return(nextTip);
        }
Beispiel #2
0
        public void TestGetNextTip3()
        {
            // Setup
            // Mock the TipManager
            Mock <ITipManager> mockTipManager = new Mock <ITipManager>();

            mockTipManager.Setup(m => m.GetPrioritizedTipGroups()).Returns(GenerateTestTipGroups());

            // Mock the TipHistoryManager
            Mock <VSTipHistoryManager> mockTipHistoryManager = new Mock <VSTipHistoryManager>();

            TipHistoryInfo tipObj1 = new TipHistoryInfo();

            tipObj1.GlobalTipId   = "General-GN001";
            tipObj1.TipLikeStatus = TipLikeEnum.LIKE;

            TipHistoryInfo tipObj2 = new TipHistoryInfo();

            tipObj2.GlobalTipId   = "Editor-ED001";
            tipObj2.TipLikeStatus = TipLikeEnum.NORMAL;

            mockTipHistoryManager.Setup(m => m.GetTipHistory()).Returns(new List <TipHistoryInfo> {
                tipObj1, tipObj2
            });

            TipCalculator tipCalculator = new TipCalculator(mockTipHistoryManager.Object, mockTipManager.Object);

            // Act
            TipInfo nextTip = tipCalculator.GetNextTip();

            // Verify
            Assert.IsNotNull(nextTip);
            Assert.AreEqual("General-GN001", nextTip.globalTipId);
        }
Beispiel #3
0
        public void TestGetNextTip2()
        {
            // Setup
            Mock <VSTipHistoryManager> mockTipHistoryManager = new Mock <VSTipHistoryManager>();
            TipHistoryInfo             tipObj1 = new TipHistoryInfo();

            tipObj1.GlobalTipId   = "General-GN001";
            tipObj1.TipLikeStatus = TipLikeEnum.LIKE;

            TipHistoryInfo tipObj2 = new TipHistoryInfo();

            tipObj2.GlobalTipId   = "Editor-ED001";
            tipObj2.TipLikeStatus = TipLikeEnum.NORMAL;

            List <TipHistoryInfo> tipsSeen = new List <TipHistoryInfo> {
                tipObj1, tipObj2
            };

            mockTipHistoryManager.Setup(m => m.GetTipHistory()).Returns(tipsSeen);

            TipCalculator tipCalculator = new TipCalculator(mockTipHistoryManager.Object);

            // Act
            TipInfo nextTip = tipCalculator.GetNextTip();

            // Verify
            Assert.IsNotNull(nextTip);
            Assert.AreEqual("General-GN001", nextTip.globalTipId);
        }
        public void TestGetNextTip2()
        {
            // Setup
            Mock <ITipHistoryManager> mockTipHistoryManager = new Mock <ITipHistoryManager>();
            List <string>             tipsSeen = new List <string> {
                "General-GN001", "Editor-ED001", "Editor-ED002"
            };

            mockTipHistoryManager.Setup(m => m.GetTipHistory()).Returns(tipsSeen);

            TipCalculator tipCalculator = new TipCalculator(mockTipHistoryManager.Object);

            // Act
            TipInfo nextTip = tipCalculator.GetNextTip();

            // Verify
            Assert.IsNotNull(nextTip);
            Assert.AreEqual("Editor-ED003", nextTip.globalTipId);
        }
        public void TestGetNextTip3()
        {
            // Setup
            // Mock the TipManager
            Mock <ITipManager> mockTipManager = new Mock <ITipManager>();

            mockTipManager.Setup(m => m.GetPrioritizedTipGroups()).Returns(GenerateTestTipGroups());

            // Mock the TipHistoryManager
            Mock <ITipHistoryManager> mockTipHistoryManager = new Mock <ITipHistoryManager>();

            mockTipHistoryManager.Setup(m => m.GetTipHistory()).Returns(new List <string> {
                "General-GN001", "Editor-ED001", "Editor-ED002"
            });

            TipCalculator tipCalculator = new TipCalculator(mockTipHistoryManager.Object, mockTipManager.Object);

            // Act
            TipInfo nextTip = tipCalculator.GetNextTip();

            // Verify
            Assert.IsNotNull(nextTip);
            Assert.AreEqual("Editor-ED003", nextTip.globalTipId);
        }