Пример #1
0
 public void GivenNoEncryptionInputWhenExecuteEncryptCalledThenShowsDialogAndReturns()
 {
     this.target.EncryptionInput = string.Empty;
     this.target.Execute("encrypt");
     AssertIt.That(
         this.mockDialogService.DialogCount,
         Is.EqualTo(1),
         "Test failed: dialog should have been called exactly once.");
 }
Пример #2
0
        public void GivenTrueWhenFalseCheckedThenShouldFail()
        {
            var exception = false;

            try
            {
                AssertIt.That(true, Is.False);
            }
            catch (AssertFailedException)
            {
                exception = true;
            }

            Assert.IsTrue(exception, "Test failed: an exception should have been thrown.");
        }
Пример #3
0
        public void GivenAnIntegerWhenComparedGreatherThanToAGreaterIntegerThenShouldFail()
        {
            var exception = false;

            try
            {
                AssertIt.That(2, Is.GreaterThan(3));
            }
            catch (AssertFailedException)
            {
                exception = true;
            }

            Assert.IsTrue(exception, "Test failed: an exception should have been thrown.");
        }
Пример #4
0
        public void GivenNullObjectWhenCheckedForNotNullThenShouldFail()
        {
            var exception = false;

            try
            {
                AssertIt.That(null, Is.NotNull <object>());
            }
            catch (AssertFailedException)
            {
                exception = true;
            }

            Assert.IsTrue(exception, "Test failed: an exception should have been thrown.");
        }
Пример #5
0
        public void GivenAnEmptyStringWhenCheckedForNotNullOrWhitespaceThenShouldFail()
        {
            var exception = false;

            try
            {
                AssertIt.That(string.Empty, Is.NotNullOrWhitespace());
            }
            catch (AssertFailedException)
            {
                exception = true;
            }

            Assert.IsTrue(exception, "Test failed: an exception should have been thrown.");
        }
Пример #6
0
        public void GivenCollectionWithUnwantedItemWhenOnlyCalledThenShouldFail()
        {
            var exception = false;

            try
            {
                var test = new[] { "abc", "def", "gh" };
                AssertIt.That(test, Has.Only <string[], string>(str => str.Length.IsEqualTo(3)));
            }
            catch (AssertFailedException)
            {
                exception = true;
            }

            Assert.IsTrue(exception, "Test failed: an exception should have been thrown.");
        }
Пример #7
0
 public void GivenViewModelWhenCreatedThenListOfAlgorithmsShouldNotBeEmpty()
 {
     AssertIt.That(this.target.Algorithms.Count(), Is.GreaterThan(0), "Test failed: list of algorithms should be initialized.");
 }
Пример #8
0
 public void GivenIsSymmetricFilterSelectedWhenAlgorithmListRequestedThenOnlyContainsSymmetricAlgorithms()
 {
     this.target.Symmetric = true;
     AssertIt.That(this.target.Algorithms.Count(), Is.GreaterThan(0), "Test failed: the filter should return some algorithms.");
     AssertIt.That(this.target.Algorithms, Has.Only <IEnumerable <ICryptoAlgorithm>, ICryptoAlgorithm>(crypto => crypto.IsSymmetric));
 }
Пример #9
0
 public void GivenNoAlgorithmSelectedWhenCanExecuteCalledThenShouldReturnFalse()
 {
     this.target.SelectedAlgorithm = null;
     AssertIt.That(this.target.CanExecute("sign"), Is.False, "Test failed: can execute should be false when no alogirthm is selected.");
 }
Пример #10
0
 public void GivenTrueWhenTrueCheckedThenShouldSucceed()
 {
     AssertIt.That(true, Is.True);
 }
Пример #11
0
 public void GivenNullParameterWhenCanExecuteCalledThenShouldReturnFalse()
 {
     AssertIt.That(this.target.CanExecute(null), Is.False, "Test failed: can execute should be false when parameter is null.");
 }
Пример #12
0
 public void GivenAnIntegerWhenComparedGreaterThanToALesserIntegerThenShouldSucceed()
 {
     AssertIt.That(3, Is.GreaterThan(2));
 }
Пример #13
0
        public void GivenCollectionWithNoUnwantedItemsWhenOnlyCalledThenShouldSucceed()
        {
            var test = new[] { "abc", "def", "ghi" };

            AssertIt.That(test, Has.Only <string[], string>(str => str.Length.IsEqualTo(3)));
        }
Пример #14
0
 public void GivenAnIntegerWhenComparedEqualToTheSameIntegerThenShouldSucceed()
 {
     AssertIt.That(2, Is.EqualTo(2));
 }
Пример #15
0
 public void GivenNonNullObjectWhenCheckedForNotNullThenShouldSucceed()
 {
     AssertIt.That(new object(), Is.NotNull <object>());
 }
Пример #16
0
 public void GivenViewModelWhenCreatedThenDecryptPropertyShouldBePopulated()
 {
     AssertIt.That(this.target.DecryptionInput, Is.NotNullOrWhitespace(), "Test failed: decryption input should not be empty.");
 }
Пример #17
0
 public void GivenViewModelWhenCreatedThenSelectedAlgorithmShouldBeSet()
 {
     AssertIt.That(this.target.SelectedAlgorithm, Is.NotNull <ICryptoAlgorithm>(), "Test failed: selected algorithm should not be null.");
 }
Пример #18
0
 public void GivenANonEmptyStringWhenCheckedForNotNullOrWhitespaceThenShouldSucceed()
 {
     AssertIt.That("Test", Is.NotNullOrWhitespace());
 }
Пример #19
0
 public void GivenNonNullParameterWhenCanExecuteCalledThenShouldReturnTrue()
 {
     AssertIt.That(this.target.CanExecute("sign"), Is.True, "Test failed: can execute should be true when parameter is not whitespace.");
 }
Пример #20
0
 public void GivenFalseWhenFalseCheckedThenShouldSucceed()
 {
     AssertIt.That(false, Is.False);
 }