Beispiel #1
0
        public void NullInitializerTest()
        {
            // Arrange
            var initializerEater = new VariableInitializerEater(Mock.Of <IEater>());

            // Assert
            Assert.Throws <ArgumentNullException>(() => initializerEater.Eat(Mock.Of <ISnapshot>(), null));
        }
Beispiel #2
0
        public void NullSnapshotTest()
        {
            // Arrange
            var initializerEater = new VariableInitializerEater(Mock.Of <IEater>());

            // Assert
            Assert.Throws <ArgumentNullException>(() => initializerEater.Eat(null, Mock.Of <IExpressionInitializer>()));
        }
Beispiel #3
0
        public void EatUnsafeCodeStackAllocInitializerTest()
        {
            // Arrange
            var expression       = Mock.Of <ICSharpExpression>();
            var itemInitializer  = Mock.Of <IUnsafeCodeStackAllocInitializer>(t => t.DimExpr == 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);
        }
Beispiel #4
0
        public void EatStubCandidateTest()
        {
            // 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.StubCandidate);
            var initializerEater = new VariableInitializerEater(eater);

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

            // Assert
            Assert.AreEqual(kind, ExpressionKind.Stub);
        }
Beispiel #5
0
        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));
        }
Beispiel #6
0
        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));
        }