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

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

            var exception = Assert.Throws <ArgumentNullException>(() => foodGroup.ForeignKeyAdd(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("foreignKey"));
            Assert.That(exception.InnerException, Is.Null);
        }
Ejemplo n.º 2
0
        public void TestThatForeignKeyAddAddsForeignKey()
        {
            var foodGroup = new FoodGroup
            {
                Identifier = Guid.NewGuid()
            };

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

            // ReSharper disable PossibleInvalidOperationException
            var foreignKeyMock = DomainObjectMockBuilder.BuildForeignKeyMock(foodGroup.Identifier.Value, foodGroup.GetType());

            // ReSharper restore PossibleInvalidOperationException

            foodGroup.ForeignKeyAdd(foreignKeyMock);
            Assert.That(foodGroup.ForeignKeys, Is.Not.Null);
            Assert.That(foodGroup.ForeignKeys, Is.Not.Empty);
            Assert.That(foodGroup.ForeignKeys.Count(), Is.EqualTo(1));
            Assert.That(foodGroup.ForeignKeys.Contains(foreignKeyMock), Is.True);
        }