public void EatVariableInitializerTest()
        {
            // Arrange
            var snapshot = Mock.Of<ISnapshot>();
            var initializer = Mock.Of<IVariableInitializer>();
            var localConstantDeclaration = Mock.Of<ILocalVariableDeclaration>(t => t.Initial == initializer);
            var typeEater = Mock.Of<ITypeEater>();
            var eater = Mock.Of<IEater>();
            var initializerEater = new Mock<IVariableInitializerEater>();
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater.Object, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot, localConstantDeclaration);

            // Assert
            initializerEater.Verify(t => t.Eat(snapshot, initializer), Times.Once);
        }
        public void AddVariableWithoutInitializerToSnapshotTest()
        {
            // Arrange
            var snapshot = new Mock<ISnapshot>();
            var type = Mock.Of<IType>();
            var localConstantDeclaration = Mock.Of<ILocalVariableDeclaration>(t => t.Type == type);
            var typeEater = Mock.Of<ITypeEater>(t => t.EatVariableType(snapshot.Object, type) == ExpressionKind.Stub);
            var eater = Mock.Of<IEater>();
            var initializerEater = Mock.Of<IVariableInitializerEater>();
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot.Object, localConstantDeclaration);

            // Assert
            snapshot.Verify(t => t.Add(ExpressionKind.Stub, localConstantDeclaration), Times.Once);
        }
        public void AddLocalVariableToSnapshotTest(ExpressionKind initKind, ExpressionKind variableKindMustBe)
        {
            // Arrange
            var snapshot = new Mock<ISnapshot>();
            var initializer = Mock.Of<IVariableInitializer>();
            var localConstantDeclaration = Mock.Of<ILocalVariableDeclaration>(t => t.Initial == initializer);
            var typeEater = Mock.Of<ITypeEater>();
            var eater = Mock.Of<IEater>();
            var initializerEater = Mock.Of<IVariableInitializerEater>(t => t.Eat(snapshot.Object, initializer) == initKind);
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot.Object, localConstantDeclaration);

            // Assert
            snapshot.Verify(t => t.Add(variableKindMustBe, localConstantDeclaration), Times.Once);
        }
Exemplo n.º 4
0
        public void AddLocalVariableToSnapshotTest(ExpressionKind initKind, ExpressionKind variableKindMustBe)
        {
            // Arrange
            var snapshot    = new Mock <ISnapshot>();
            var initializer = Mock.Of <IVariableInitializer>();
            var localConstantDeclaration = Mock.Of <ILocalVariableDeclaration>(t => t.Initial == initializer);
            var typeEater        = Mock.Of <ITypeEater>();
            var eater            = Mock.Of <IEater>();
            var initializerEater = Mock.Of <IVariableInitializerEater>(t => t.Eat(snapshot.Object, initializer) == initKind);
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot.Object, localConstantDeclaration);

            // Assert
            snapshot.Verify(t => t.Add(variableKindMustBe, localConstantDeclaration), Times.Once);
        }
Exemplo n.º 5
0
        public void EatVariableInitializerTest()
        {
            // Arrange
            var snapshot    = Mock.Of <ISnapshot>();
            var initializer = Mock.Of <IVariableInitializer>();
            var localConstantDeclaration = Mock.Of <ILocalVariableDeclaration>(t => t.Initial == initializer);
            var typeEater        = Mock.Of <ITypeEater>();
            var eater            = Mock.Of <IEater>();
            var initializerEater = new Mock <IVariableInitializerEater>();
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater.Object, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot, localConstantDeclaration);

            // Assert
            initializerEater.Verify(t => t.Eat(snapshot, initializer), Times.Once);
        }
Exemplo n.º 6
0
        public void AddVariableWithoutInitializerToSnapshotTest()
        {
            // Arrange
            var snapshot = new Mock <ISnapshot>();
            var type     = Mock.Of <IType>();
            var localConstantDeclaration = Mock.Of <ILocalVariableDeclaration>(t => t.Type == type);
            var typeEater        = Mock.Of <ITypeEater>(t => t.EatVariableType(snapshot.Object, type) == ExpressionKind.Stub);
            var eater            = Mock.Of <IEater>();
            var initializerEater = Mock.Of <IVariableInitializerEater>();
            var localConstantDeclarationEater = new LocalVariableDeclarationEater(eater, initializerEater, typeEater);

            // Act
            localConstantDeclarationEater.Eat(snapshot.Object, localConstantDeclaration);

            // Assert
            snapshot.Verify(t => t.Add(ExpressionKind.Stub, localConstantDeclaration), Times.Once);
        }