コード例 #1
0
        public void GetEnum_NoValueFound()
        {
            var choiceGuids = GetOrderedGuids <SingleChoiceFieldChoices>();

            rsapiProvider.Setup(SetupExpr(choiceGuids)).Returns(GetResults(choiceGuids, 1));

            var choiceCache = new ChoiceCache(rsapiProvider.Object);

            Assert.Throws <InvalidOperationException>(() => choiceCache.GetEnum <SingleChoiceFieldChoices>(1000));
        }
コード例 #2
0
        public void GetEnum_OnlyFetchesFromServerOnce()
        {
            var choiceGuids = GetOrderedGuids <SingleChoiceFieldChoices>();
            var setupExpr   = SetupExpr(choiceGuids);

            rsapiProvider.SetupSequence(setupExpr).Returns(GetResults(choiceGuids, 1));

            var choiceCache = new ChoiceCache(rsapiProvider.Object);

            Assert.AreEqual(SingleChoiceFieldChoices.SingleChoice1, choiceCache.GetEnum <SingleChoiceFieldChoices>(1));
            Assert.AreEqual(SingleChoiceFieldChoices.SingleChoice1, choiceCache.GetEnum <SingleChoiceFieldChoices>(1));

            rsapiProvider.Verify(setupExpr, Times.Once);
        }
コード例 #3
0
        public void GetEnum_RefreshesForEachCacheInstance()
        {
            var choiceGuids = GetOrderedGuids <SingleChoiceFieldChoices>();
            var setupExpr   = SetupExpr(choiceGuids);

            rsapiProvider
            .SetupSequence(setupExpr)
            .Returns(GetResults(choiceGuids, 1))
            .Returns(GetResults(choiceGuids, 11));
            var choiceCache1 = new ChoiceCache(rsapiProvider.Object);
            var choiceCache2 = new ChoiceCache(rsapiProvider.Object);

            Assert.AreEqual(SingleChoiceFieldChoices.SingleChoice1, choiceCache1.GetEnum <SingleChoiceFieldChoices>(1));
            Assert.AreEqual(SingleChoiceFieldChoices.SingleChoice1, choiceCache2.GetEnum <SingleChoiceFieldChoices>(11));

            rsapiProvider.Verify(setupExpr, Times.Exactly(2));
        }
コード例 #4
0
        public void GetEnum_RefreshesForDifferentEnumerationTypes()
        {
            var singleChoiceGuids = GetOrderedGuids <SingleChoiceFieldChoices>();
            var multiChoiceGuids  = GetOrderedGuids <MultipleChoiceFieldChoices>();
            var singleSetupExpr   = SetupExpr(singleChoiceGuids);
            var multiSetupExpr    = SetupExpr(multiChoiceGuids);

            rsapiProvider.SetupSequence(singleSetupExpr).Returns(GetResults(singleChoiceGuids, 1));
            rsapiProvider.SetupSequence(multiSetupExpr).Returns(GetResults(multiChoiceGuids, 11));

            var choiceCache = new ChoiceCache(rsapiProvider.Object);

            Assert.AreEqual(SingleChoiceFieldChoices.SingleChoice1, choiceCache.GetEnum <SingleChoiceFieldChoices>(1));
            Assert.AreEqual(MultipleChoiceFieldChoices.MultipleChoice1, choiceCache.GetEnum <MultipleChoiceFieldChoices>(11));

            rsapiProvider.Verify(singleSetupExpr, Times.Once);
            rsapiProvider.Verify(multiSetupExpr, Times.Once);
        }
コード例 #5
0
        public void GetEnum_TypeIsNotEnum()
        {
            var choiceCache = new ChoiceCache(rsapiProvider.Object);

            Assert.Throws <NotSupportedException>(() => choiceCache.GetEnum <GravityLevel2>(1));
        }