Exemplo n.º 1
0
        public void CreateICommandJsonConvertProviderInstance_WhenParametersAreValid()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            // Act
            var actualInstance = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            // Assert
            Assert.That(actualInstance, Is.Not.Null.And.InstanceOf <ICommandJsonConvertProvider>());
        }
Exemplo n.º 2
0
        public void InvokeIJsonConvertProvider_DeserializeObjectMethodOnceWithCorrectParameter_WhenICommandIsValid()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            var value = "any string";

            // Act
            commandJsonConvertProvider.DeserializeCommand(value);

            // Assert
            jsonConvertProvider.Verify(p => p.DeserializeObject <Command>(value), Times.Once);
        }
Exemplo n.º 3
0
        public void ReturnNull_WhenValueParameterIsNull()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            string value = null;

            // Act
            var actualResult = commandJsonConvertProvider.DeserializeCommand(value);

            // Assert
            Assert.That(actualResult, Is.Null);
        }
Exemplo n.º 4
0
        public void InvokeIJsonConvertProvider_SerializeObjectMethodOnceWithCorrectParameter_WhenICommandIsValid()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            var command = new Mock <ICommand>();

            // Act
            commandJsonConvertProvider.SerializeCommand(command.Object);

            // Assert
            jsonConvertProvider.Verify(p => p.SerializeObject(command.Object), Times.Once);
        }
Exemplo n.º 5
0
        public void ReturnNull_WhenICommandParameterIsNull()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            ICommand command = null;

            // Act
            var actualResult = commandJsonConvertProvider.SerializeCommand(command);

            // Assert
            Assert.That(actualResult, Is.Null);
        }
Exemplo n.º 6
0
        public void ReturnCorrectResult_WhenValueParameterIsValid()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            var value = "any string";

            var expectedResult = new Mock <Command>();

            jsonConvertProvider.Setup(p => p.DeserializeObject <Command>(It.IsAny <string>())).Returns(expectedResult.Object);

            // Act
            var actualResult = commandJsonConvertProvider.DeserializeCommand(value);

            // Assert
            Assert.That(actualResult, Is.EqualTo(expectedResult.Object).And.InstanceOf <ICommand>());
        }
Exemplo n.º 7
0
        public void ReturnCorrectResult_WhenICommandParameterIsValid()
        {
            // Arrange
            var jsonConvertProvider = new Mock <IJsonConvertProvider>();

            var commandJsonConvertProvider = new CommandJsonConvertProvider(jsonConvertProvider.Object);

            var command = new Mock <ICommand>();

            var expectedResult = "expected result";

            jsonConvertProvider.Setup(p => p.SerializeObject(It.IsAny <ICommand>())).Returns(expectedResult);

            // Act
            var actualResult = commandJsonConvertProvider.SerializeCommand(command.Object);

            // Assert
            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }