コード例 #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);
 }