Ejemplo n.º 1
0
        public void TestThatTranslationAddThrowsArgumentNullExceptionWhenTranslationIsNull()
        {
            var foodGroup = new FoodGroup();

            Assert.That(foodGroup, Is.Not.Null);

            var exception = Assert.Throws <ArgumentNullException>(() => foodGroup.TranslationAdd(null));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Empty);
            Assert.That(exception.ParamName, Is.EqualTo("translation"));
            Assert.That(exception.InnerException, Is.Null);
        }
Ejemplo n.º 2
0
        public void TestThatTranslationAddAddsTranslation()
        {
            var foodGroup = new FoodGroup
            {
                Identifier = Guid.NewGuid()
            };

            Assert.That(foodGroup, Is.Not.Null);
            Assert.That(foodGroup.Translations, Is.Not.Null);
            Assert.That(foodGroup.Translations, Is.Empty);

            // ReSharper disable PossibleInvalidOperationException
            var translationMock = DomainObjectMockBuilder.BuildTranslationMock(foodGroup.Identifier.Value);

            // ReSharper restore PossibleInvalidOperationException

            foodGroup.TranslationAdd(translationMock);
            Assert.That(foodGroup.Translations, Is.Not.Null);
            Assert.That(foodGroup.Translations, Is.Not.Empty);
            Assert.That(foodGroup.Translations.Count(), Is.EqualTo(1));
            Assert.That(foodGroup.Translations.Contains(translationMock), Is.True);
        }