Exemplo n.º 1
0
        public void CreateGame_ThrowsIfCreateGameFailed()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(connectionId))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            #region ScenarioHandler
            var scenarioHandler = new Mock <IScenarioHandler>();

            scenarioHandler.Setup(a => a.ValidScenario(It.IsAny <string>()))
            .Returns(true);
            #endregion

            var hub = this.GetHub(connectionId,
                                  userHandler: userHandler,
                                  scenarioHandler: scenarioHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }
Exemplo n.º 2
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.");
 }
Exemplo n.º 3
0
        public void LeaveGame_ThrowsIfUserDoesntExist()
        {
            var connectionId = "123";

            var hub = this.GetHub(connectionId);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.LeaveGame("game-id");
            });
        }
Exemplo n.º 4
0
        public void CreateGame_ThrowsIfUserDoesntExist()
        {
            var connectionId = "123";

            var hub = this.GetHub(connectionId);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }
Exemplo n.º 5
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.");
        }
Exemplo n.º 6
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.");
        }
Exemplo n.º 7
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.");
        }
Exemplo n.º 8
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.");
        }
Exemplo n.º 9
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.");
        }
Exemplo n.º 10
0
        public void LeaveGame_ThrowsIfGameDoesntExist()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(It.IsAny <string>()))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            var hub = this.GetHub(connectionId, userHandler: userHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.LeaveGame("game-id");
            });
        }
Exemplo n.º 11
0
        public void CreateGame_ThrowsIfScenarioDoesntExist()
        {
            var connectionId = "123";

            #region UserHandler
            var userHandler = new Mock <IUserHandler>();

            userHandler.Setup(a => a.GetUser(connectionId))
            .Returns(new User(connectionId, new RegisteredClient()));
            #endregion

            var hub = this.GetHub(connectionId, userHandler: userHandler);

            AssertIt.Throws <InvalidOperationException>(() =>
            {
                hub.CreateGame("game-name", "scenario");
            });
        }
Exemplo n.º 12
0
 public void GivenViewModelWhenCreatedThenListOfAlgorithmsShouldNotBeEmpty()
 {
     AssertIt.That(this.target.Algorithms.Count(), Is.GreaterThan(0), "Test failed: list of algorithms should be initialized.");
 }
Exemplo n.º 13
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));
 }
Exemplo n.º 14
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.");
 }
Exemplo n.º 15
0
 public void GivenTrueWhenTrueCheckedThenShouldSucceed()
 {
     AssertIt.That(true, Is.True);
 }
Exemplo n.º 16
0
 public void GivenNullParameterWhenCanExecuteCalledThenShouldReturnFalse()
 {
     AssertIt.That(this.target.CanExecute(null), Is.False, "Test failed: can execute should be false when parameter is null.");
 }
Exemplo n.º 17
0
 public void GivenAnIntegerWhenComparedGreaterThanToALesserIntegerThenShouldSucceed()
 {
     AssertIt.That(3, Is.GreaterThan(2));
 }
Exemplo n.º 18
0
        public void GivenCollectionWithNoUnwantedItemsWhenOnlyCalledThenShouldSucceed()
        {
            var test = new[] { "abc", "def", "ghi" };

            AssertIt.That(test, Has.Only <string[], string>(str => str.Length.IsEqualTo(3)));
        }
Exemplo n.º 19
0
 public void GivenAnIntegerWhenComparedEqualToTheSameIntegerThenShouldSucceed()
 {
     AssertIt.That(2, Is.EqualTo(2));
 }
Exemplo n.º 20
0
 public void GivenNonNullObjectWhenCheckedForNotNullThenShouldSucceed()
 {
     AssertIt.That(new object(), Is.NotNull <object>());
 }
Exemplo n.º 21
0
 public void GivenViewModelWhenCreatedThenDecryptPropertyShouldBePopulated()
 {
     AssertIt.That(this.target.DecryptionInput, Is.NotNullOrWhitespace(), "Test failed: decryption input should not be empty.");
 }
Exemplo n.º 22
0
 public void GivenViewModelWhenCreatedThenSelectedAlgorithmShouldBeSet()
 {
     AssertIt.That(this.target.SelectedAlgorithm, Is.NotNull <ICryptoAlgorithm>(), "Test failed: selected algorithm should not be null.");
 }
Exemplo n.º 23
0
 public void GivenANonEmptyStringWhenCheckedForNotNullOrWhitespaceThenShouldSucceed()
 {
     AssertIt.That("Test", Is.NotNullOrWhitespace());
 }
Exemplo n.º 24
0
 public void GivenNonNullParameterWhenCanExecuteCalledThenShouldReturnTrue()
 {
     AssertIt.That(this.target.CanExecute("sign"), Is.True, "Test failed: can execute should be true when parameter is not whitespace.");
 }
Exemplo n.º 25
0
 public void GivenFalseWhenFalseCheckedThenShouldSucceed()
 {
     AssertIt.That(false, Is.False);
 }