Ejemplo n.º 1
0
 public void ShouldContainKey_WhenTrue_ShouldNotThrow()
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("key", "value");
     dictionary.ShouldContainKey("key");
     dictionary.ShouldNotContainKey("rob");
 }
Ejemplo n.º 2
0
        public void ShouldNotContainKey_WhenTrue_ShouldNotThrow()
        {
            var dictionary = new Dictionary <string, string> {
                { "key", "value" }
            };

            dictionary.ShouldNotContainKey("rob");
        }
        public void ShouldNotContainKey()
        {
            DocExampleWriter.Document(() =>
            {
                var websters = new Dictionary<string, string>();
                websters.Add("Chazzwazzers", "What Australians would have called a bull frog.");

                websters.ShouldNotContainKey("Chazzwazzers");
            }, _testOutputHelper);
        }
        public void ShouldNotContainKey()
        {
            DocExampleWriter.Document(() =>
            {
                var websters = new Dictionary <string, string>();
                websters.Add("Chazzwazzers", "What Australians would have called a bull frog.");

                websters.ShouldNotContainKey("Chazzwazzers");
            }, _testOutputHelper);
        }
Ejemplo n.º 5
0
        public void RemoveStopWords()
        {
            // Arrange
            List <string> stopWords = new List <string>()
            {
                "foo",
                "bar",
                "baz"
            };

            Dictionary <string, int> dictionaryInput = new Dictionary <string, int>
            {
                { "the", 2 },
                { "quick", 1 },
                { "brown", 1 },
                { "fox", 1 },
                { "jumps", 1 },
                { "over", 1 },
                { "lazy", 1 },
                { "dog", 1 },
                { "foo", 1 },
                { "bar", 2 },
                { "baz", 3 }
            };

            // Act
            Dictionary <string, int> result = TextAnalyzer.RemoveStopWords(dictionaryInput, stopWords);

            // Assert
            result.Count.ShouldBe(8);
            result.ShouldNotContainKey("foo");
            result.ShouldNotContainKey("bar");
            result.ShouldNotContainKey("baz");
            result.ShouldContain(new KeyValuePair <string, int>("the", 2));
            result.ShouldContain(new KeyValuePair <string, int>("quick", 1));
            result.ShouldContain(new KeyValuePair <string, int>("brown", 1));
            result.ShouldContain(new KeyValuePair <string, int>("fox", 1));
            result.ShouldContain(new KeyValuePair <string, int>("jumps", 1));
            result.ShouldContain(new KeyValuePair <string, int>("over", 1));
            result.ShouldContain(new KeyValuePair <string, int>("lazy", 1));
            result.ShouldContain(new KeyValuePair <string, int>("dog", 1));
        }
Ejemplo n.º 6
0
        public void ToolsetDefinitionLocationsIsDefault()
        {
            var projectCollection = new ProjectCollection();
            IDictionary <string, string> toolsetProperties
                = new Dictionary <string, string>();

            foreach (Toolset toolset in projectCollection.Toolsets)
            {
                foreach (KeyValuePair <string, ProjectPropertyInstance> properties in toolset.Properties)
                {
                    toolsetProperties[properties.Value.Name] = properties.Value.EvaluatedValue;
                }
            }

            toolsetProperties.ShouldContainKey("MSBuildSDKsPath");
            toolsetProperties.ShouldContainKey("RoslynTargetsPath");
            toolsetProperties["MSBuildSDKsPath"].ShouldNotBeNullOrEmpty();
            toolsetProperties["RoslynTargetsPath"].ShouldNotBeNullOrEmpty();

            toolsetProperties.ShouldNotContainKey("VCTargetsPath");
            toolsetProperties.ShouldNotContainKey("MSBuildToolsRoot");
            toolsetProperties.ShouldNotContainKey("MSBuildExtensionsPath");
        }
Ejemplo n.º 7
0
        public void ApplicationError_SecurityException()
        {
            // Arrange
            ShimHttpServerUtility.AllInstances.GetLastError = (instance) => new Exception(String.Empty, new ShimSecurityException
            {
                SecurityTypeGet = () => Enums.SecurityExceptionType.RoleAccess
            });

            // Act
            _mvcApplication.Invoke("Application_Error", new object[] { null, null });

            // Assert
            _redirectionPath.ShouldBe(HardErrorRedirectPath);
            _errorMessage.ShouldBeEmpty();
            _applicationState.ShouldNotContainKey(ApplicationStateErrorEntryKey);
        }
Ejemplo n.º 8
0
        public void WorksAsDictionaryKey()
        {
            // arrange
            var dictionary = new Dictionary <NamespacedName, string>();
            var name1      = new NamespacedName("ns", "n1");
            var name2      = new NamespacedName("ns", "n2");
            var name3      = new NamespacedName("ns", "n3");

            // act
            dictionary[name1] = "one";
            dictionary[name1] = "one again";
            dictionary[name2] = "two";

            // assert
            dictionary.ShouldSatisfyAllConditions(
                () => dictionary.ShouldContainKeyAndValue(name1, "one again"),
                () => dictionary.ShouldContainKeyAndValue(name2, "two"),
                () => dictionary.ShouldNotContainKey(name3));
        }
Ejemplo n.º 9
0
        public void ShouldCallAnObjectCreatingCallbackInARootEnumerableConditionally()
        {
            using (var mapper = Mapper.CreateNew())
            {
                var createdAddressesByIndex = new Dictionary <int, string>();

                mapper.WhenMapping
                .From <PersonViewModel>()
                .ToANew <Person>()
                .Before
                .CreatingInstancesOf <Address>()
                .If((s, t, i) => (i == 1) || (i == 2))
                .Call(ctx => createdAddressesByIndex[ctx.EnumerableIndex.GetValueOrDefault()] = ctx.Source.AddressLine1);

                var source = new[]
                {
                    new PersonViewModel {
                        AddressLine1 = "Zero!"
                    },
                    new PersonViewModel {
                        AddressLine1 = "One!"
                    },
                    new PersonViewModel {
                        AddressLine1 = "Two!"
                    }
                };

                var result = mapper.Map(source).ToANew <Person[]>();

                result.Select(p => p.Address.Line1).ShouldBe("Zero!", "One!", "Two!");

                createdAddressesByIndex.ShouldNotContainKey(0);
                createdAddressesByIndex.ShouldContainKeyAndValue(1, "One!");
                createdAddressesByIndex.ShouldContainKeyAndValue(2, "Two!");
            }
        }
Ejemplo n.º 10
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldNotContainKey(GuidKey, "Some additional context");
 }
Ejemplo n.º 11
0
 protected override void ShouldThrowAWobbly()
 {
     _dictionary.ShouldNotContainKey(ThingKey);
 }
Ejemplo n.º 12
0
        public void ShouldNotContainKey()
        {
            var websters = new Dictionary<string, string>();
            websters.Add("Chazzwazzers", "What Australians would have called a bull frog.");

            websters.ShouldNotContainKey("Chazzwazzers");
        }