Ejemplo n.º 1
0
 public void IsJoinedTest()
 {
     var mock = new Mock<Services>();
     mock.Setup(
         x => x.IsJoined(new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } }))
         .Returns(true);
     var s = new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } };
     var expected = false; // The Key is never the same
     var target = mock.Object;
     var actual = target.IsJoined(s);
     Assert.AreEqual(expected, actual);
     Assert.IsNotNull(actual);
 }
Ejemplo n.º 2
0
 public void SendTest()
 {
     var message = new Message
     {
         Algorithm = CryptoAlgorithm.None,
         Payload = new byte[] { 1, 2, 3 },
         Sender = new User { Name = "Florian" }
     };
     var session = new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } };
     var mock = new Mock<IMessagingService>();
     mock.Setup(x => x.Send(message, session));
     var target = mock.Object;
     var sender = new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } };
     target.Send(message, sender);
     mock.Verify(x => x.Send(message, sender));
 }
Ejemplo n.º 3
0
 public void LeaveTest()
 {
     var mock = new Mock<Services>();
     mock.Setup(
         x => x.Leave(new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } }));
     var target = mock.Object;
     var session = new Session { ExpiryDate = DateTime.Today.AddDays(1), User = new User { Name = "Florian" } };
     target.Leave(session);
     Assert.IsFalse(target.IsJoined(session));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Leaves the user.
 /// </summary>
 private void LeaveUser()
 {
     this.userProxy.Leave(this.currentSession);
     this.currentSession = null;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Joins the user.
        /// </summary>
        /// <param name="username">The username.</param>
        private void JoinUser(string username)
        {
            var user = new User
            {
                Name = username
            };

            this.currentSession = this.userProxy.Join(user);
        }