Пример #1
0
        public void NotThrowWhenGivenFieldThatDoesNotExistToSet()
        {
            var item = new DummyDynamicFieldsContainer();

            TestDelegate trySetValueCall = () => item.TrySetValue(DummyDynamicFieldsContainer.NonexistentFieldName, "foo");

            Assert.DoesNotThrow(trySetValueCall);
        }
Пример #2
0
        public void NotThrowWhenSettingFieldThatThrows()
        {
            var item = new DummyDynamicFieldsContainer();

            TestDelegate trySetValueCall = () => item.TrySetValue(DummyDynamicFieldsContainer.FieldThatThrowsName, "foo");

            Assert.DoesNotThrow(trySetValueCall);
        }
Пример #3
0
        public void ReturnFalseWhenFieldDoesNotExist()
        {
            IDynamicFieldsContainer container = new DummyDynamicFieldsContainer();

            bool result = container.GetBoolean(DummyDynamicFieldsContainer.NonexistentFieldName);

            Assert.IsFalse(result, "False should be returned for field that doesn't exist.");
        }
Пример #4
0
        public void ReturnFalseWhenGivenNullOrWhiteSpaceField(string nullOrEmptyFieldName)
        {
            IDynamicFieldsContainer container = new DummyDynamicFieldsContainer();

            bool result = container.GetBoolean(nullOrEmptyFieldName);

            Assert.IsFalse(result, "Null or empty field should always come back false.");
        }
Пример #5
0
        public void SetsValueOfValidField()
        {
            const string expected = "my new value";
            var          item     = new DummyDynamicFieldsContainer();

            item.TrySetValue(DummyDynamicFieldsContainer.StringFieldName, expected);

            Assert.AreEqual(expected, item.String);
        }
Пример #6
0
        public void ReturnFalseWhenValueIsNull()
        {
            IDynamicFieldsContainer container = new DummyDynamicFieldsContainer {
                String = null
            };

            bool result = container.GetBoolean(DummyDynamicFieldsContainer.StringFieldName);

            Assert.IsFalse(result, "A null field should return false.");
        }
Пример #7
0
        public void ReturnValueOfBooleanString(bool expectedValue)
        {
            IDynamicFieldsContainer container = new DummyDynamicFieldsContainer {
                String = expectedValue.ToString()
            };

            bool result = container.GetBoolean(DummyDynamicFieldsContainer.StringFieldName);

            Assert.AreEqual(expectedValue, result, "String boolean value was not returned.");
        }
Пример #8
0
        public void ReturnValueOfBooleanField(bool expectedValue)
        {
            IDynamicFieldsContainer container = new DummyDynamicFieldsContainer {
                Boolean = expectedValue
            };

            bool result = container.GetBoolean(DummyDynamicFieldsContainer.BooleanFieldName);

            Assert.AreEqual(expectedValue, result, "Boolean value was not returned.");
        }
Пример #9
0
        public void FilterOutItemsNotMatchingSingleId()
        {
            Guid idToMatch    = Guid.NewGuid();
            var  expectedItem = new DummyDynamicFieldsContainer(idToMatch);
            var  items        = new List <IDynamicFieldsContainer> {
                new DummyDynamicFieldsContainer(), expectedItem, new DummyDynamicFieldsContainer()
            };

            List <IDynamicFieldsContainer> result = items.FilterByTaxa(DummyDynamicFieldsContainer.TaxaFieldName, new[] { idToMatch }).ToList();

            Assert.AreEqual(1, result.Count, "Only one item should have matched the given filter.");
            Assert.AreEqual(expectedItem, result.Single(), "Incorrect item returned.");
        }
Пример #10
0
        public void FilterOutItemsNotMatchAnyGivenId()
        {
            Guid idToMatch1    = Guid.NewGuid();
            Guid idToMatch2    = Guid.NewGuid();
            var  expectedItem1 = new DummyDynamicFieldsContainer(idToMatch1);
            var  expectedItem2 = new DummyDynamicFieldsContainer(idToMatch2);
            var  expectedItem3 = new DummyDynamicFieldsContainer(idToMatch1, idToMatch2);
            var  items         = new List <IDynamicFieldsContainer> {
                expectedItem1, new DummyDynamicFieldsContainer(), expectedItem2, expectedItem3, new DummyDynamicFieldsContainer()
            };

            List <IDynamicFieldsContainer> result = items.FilterByTaxa(DummyDynamicFieldsContainer.TaxaFieldName, new[] { idToMatch1, idToMatch2 }).ToList();

            Assert.AreEqual(3, result.Count, "Three items should have matched the given filter.");
            Assert.Contains(expectedItem1, result, "Resulting set should have contained item with first ID.");
            Assert.Contains(expectedItem2, result, "Resulting set should have contained item with second ID.");
            Assert.Contains(expectedItem3, result, "Resulting set should have contained item with both IDs.");
        }