public void EncryptData_should_be_enabled_when_encryption_key_is_given(bool encryptionKeyEntered) { // given var configurationMock = new Mock <IConfiguration>(); configurationMock .Setup(x => x.EncryptionKey) .Returns(encryptionKeyEntered ? "key" : null); _configurationServiceMock .Setup(x => x.GetConfiguration()) .Returns(configurationMock.Object); // when var result = _controller.EncryptData() as ViewResult; // then Assert.That(result.ViewName, Is.EqualTo("EncryptData")); var model = result.Model as EncryptedDataViewModel; Assert.That(model.IsEnabled, Is.EqualTo(encryptionKeyEntered)); }