public void EatExpressionInitializerTest()
        {
            // Arrange
            var expression = Mock.Of<ICSharpExpression>();
            var itemInitializer = Mock.Of<IExpressionInitializer>(t => t.Value == expression);
            var snapshot = Mock.Of<ISnapshot>();
            var eater = Mock.Of<IEater>(t => t.Eat(snapshot, expression) == ExpressionKind.Mock);
            var initializerEater = new VariableInitializerEater(eater);

            // Act
            var kind = initializerEater.Eat(snapshot, itemInitializer);

            // Assert
            Assert.AreEqual(kind, ExpressionKind.Mock);
        }
        public void AddItemToSnapshotTest()
        {
            // Arrange
            var expression = Mock.Of<ICSharpExpression>();
            var itemInitializer = Mock.Of<IExpressionInitializer>(t => t.Value == expression);
            var arrayInit = Mock.Of<IArrayInitializer>();
            Mock.Get(arrayInit).Setup(t => t.ElementInitializers)
                .Returns(new TreeNodeCollection<IVariableInitializer>(new[] { itemInitializer }));
            var snapshot = new Mock<ISnapshot>();
            var eater = Mock.Of<IEater>(t => t.Eat(snapshot.Object, expression) == ExpressionKind.Stub);
            var initializerEater = new VariableInitializerEater(eater);

            // Act
            initializerEater.Eat(snapshot.Object, arrayInit);

            // Assert
            snapshot.Verify(t => t.Add(ExpressionKind.Stub, itemInitializer));
        }
        public void EatArrayInitializerTest()
        {
            // Arrange
            var expression = Mock.Of<ICSharpExpression>();
            var itemInitializer = Mock.Of<IExpressionInitializer>(t => t.Value == expression);
            var arrayInit = Mock.Of<IArrayInitializer>();
            Mock.Get(arrayInit).Setup(t => t.ElementInitializers)
                .Returns(new TreeNodeCollection<IVariableInitializer>(new[] {itemInitializer}));
            var snapshot = Mock.Of<ISnapshot>();
            var eater = new Mock<IEater>();
            var initializerEater = new VariableInitializerEater(eater.Object);

            // Act
            var kind = initializerEater.Eat(snapshot, arrayInit);

            // Assert
            Assert.AreEqual(kind, ExpressionKind.StubCandidate);
            eater.Verify(t => t.Eat(snapshot, expression));
        }
        public void NullSnapshotTest()
        {
            // Arrange
            var initializerEater = new VariableInitializerEater(Mock.Of<IEater>());

            // Assert
            Assert.Throws<ArgumentNullException>(() => initializerEater.Eat(null, Mock.Of<IExpressionInitializer>()));
        }
        public void NullInitializerTest()
        {
            // Arrange
            var initializerEater = new VariableInitializerEater(Mock.Of<IEater>());

            // Assert
            Assert.Throws<ArgumentNullException>(() => initializerEater.Eat(Mock.Of<ISnapshot>(), null));
        }