Inheritance: IIntellisenseProvider
        public void DateTimeIntellisenseProvider_Constructor_Create_ExpectCorrectMembers()
        {
            //------------Setup for test--------------------------
            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();

            //------------Assert Results-------------------------
            Assert.IsNotNull(dateTimeIntellisenseProvider.Optional);
            Assert.IsTrue(dateTimeIntellisenseProvider.IntellisenseResults.Count > 0);
        }
        public void DateTimeIntellisenseProvider_Construct_DefaultPropertiesAreSet()
        {
            var provider = new DateTimeIntellisenseProvider();

            Assert.IsFalse(provider.HandlesResultInsertion);
            Assert.AreEqual(IntellisenseProviderType.NonDefault, provider.IntellisenseProviderType);
            Assert.IsNotNull(provider.IntellisenseResults);
            Assert.AreEqual(24, provider.IntellisenseResults.Count);
            Assert.IsFalse(provider.Optional);
        }
        public void DateTimeIntellisenseProvider_Constructor_Parameters_ExpectCorrectMembers()
        {
            //------------Setup for test--------------------------
            var res = new Mock<IIntellisenseResult>();
            res.Setup(a => a.ErrorCode).Returns(enIntellisenseErrorCode.InvalidRecordsetNotation);
            res.Setup(a => a.Type).Returns(enIntellisenseResultType.Error);
            res.Setup(a => a.IsClosedRegion).Returns(true);
            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider(new List<IIntellisenseResult> { res.Object });

            //------------Assert Results-------------------------
            Assert.IsNotNull(dateTimeIntellisenseProvider.Optional);
            Assert.IsTrue(dateTimeIntellisenseProvider.IntellisenseResults.Count == 1);
            Assert.AreEqual(res.Object, dateTimeIntellisenseProvider.IntellisenseResults[0]);
        }
        public void DateTimeIntellisenseProvider_GetIntellisenseResults_PartialMethodMatch_ClosestMatchesReturned()
        {
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 1,
                    InputText = "d",
                    IsInCalculateMode = false,
                    DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
                };

            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();
            IList<IntellisenseProviderResult> results = dateTimeIntellisenseProvider.GetIntellisenseResults(context);

            Assert.AreEqual(6, results.Count);
        }
        static IIntellisenseProvider GetProvider(string providerName)
        {
            IIntellisenseProvider provider = new DefaultIntellisenseProvider();

            switch(providerName.Trim())
            {
                case "Calculate":
                    provider = new CalculateIntellisenseProvider();
                    break;
                case "File":
                    var fileSystemIntellisenseProvider = new FileSystemIntellisenseProvider { FileSystemQuery = ScenarioContext.Current.Get<IFileSystemQuery>("fileQueryHelper") };
                    provider = fileSystemIntellisenseProvider;
                    ScenarioContext.Current.Add("isFileProvider", true);
                    break;
                case "DateTime":
                    provider = new DateTimeIntellisenseProvider();
                    break;
            }

            return provider;
        }
        public void DateTimeIntellisenseProvider_Dispose()
        {
            //------------Setup for test--------------------------
            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();
            dateTimeIntellisenseProvider.Dispose();


            //------------Assert Results-------------------------
            Assert.IsNull(dateTimeIntellisenseProvider.IntellisenseResults);

        }
        public void DateTimeIntellisenseProvider_GetIntellisenseResults_ErrorResult_ExpectResultIfNonErrorType()
        {
            //------------Setup for test--------------------------
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 1,
                InputText = "dod",
                IsInCalculateMode = false,
                DesiredResultSet = IntellisenseDesiredResultSet.EntireSet
            };

            var res = new Mock<IIntellisenseResult>();
            var opt = new Mock<IDataListVerifyPart>();
            opt.Setup(a => a.DisplayValue).Returns("dora");

            res.Setup(a => a.ErrorCode).Returns(enIntellisenseErrorCode.InvalidRecordsetNotation);
            res.Setup(a => a.Type).Returns(enIntellisenseResultType.Selectable);
            res.Setup(a => a.IsClosedRegion).Returns(false);
            res.Setup(a => a.Message).Returns("bob");
            res.Setup(a => a.Option).Returns(opt.Object);
            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider(new List<IIntellisenseResult> { res.Object });
            var count = dateTimeIntellisenseProvider.IntellisenseResults.Count;

            //------------Execute Test---------------------------

            var results = dateTimeIntellisenseProvider.GetIntellisenseResults(context);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(count, 1); // check that there was stuff to add

        }
 public void DateTimeIntellisenseProvider_GetIntellisenseResults_ContextIsNull_ResultCountIsZero()
 {
     //------------Execute Test---------------------------
     var getResults = new DateTimeIntellisenseProvider().GetIntellisenseResults(null);
     //------------Assert Results-------------------------
     Assert.AreEqual(0, getResults.Count);
 }
        public void DateTimeIntellisenseProvider_GetIntellisenseResultsImpl_EntireResultSet()
        {
            //------------Setup for test--------------------------
            var context = new IntellisenseProviderContext
            {
                CaretPosition = 1,
                InputText = "d",
                IsInCalculateMode = false,
                DesiredResultSet = IntellisenseDesiredResultSet.EntireSet
            };

            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();
            var count = dateTimeIntellisenseProvider.IntellisenseResults.Count;

            //------------Execute Test---------------------------

            var results = dateTimeIntellisenseProvider.GetIntellisenseResultsImpl(context);

            //------------Assert Results-------------------------
            Assert.AreEqual(count, results.Count);

        }
        public void DateTimeIntellisenseProvider_PerformInsertion_ExpectException()
        {
            //------------Setup for test--------------------------
            var context = new IntellisenseProviderContext
                {
                    CaretPosition = 1,
                    InputText = "d",
                    IsInCalculateMode = false,
                    DesiredResultSet = IntellisenseDesiredResultSet.ClosestMatch
                };

            var dateTimeIntellisenseProvider = new DateTimeIntellisenseProvider();


            //------------Execute Test---------------------------

            dateTimeIntellisenseProvider.PerformResultInsertion("blah", context);

            //------------Assert Results-------------------------
        }