コード例 #1
0
        public void SourceAndDestinationAreNotSame()
        {
            #region Setup for test
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            repoInstance.Setup(ent => ent.Add(It.IsAny<MessagePing>())).Returns(dummyMessage);
            MessagePing testData = new MessagePing()
            {
                Source = "+919840200524",
                Destination = "+919840200524",
                Message = "Hello!",
                MessageSentUTC = DateTime.UtcNow
            };
            #endregion

            #region Test and Assert
            bool postResult = testSubject.PostMessage(testData);
            Assert.IsFalse(postResult);
            #endregion
        }
コード例 #2
0
 public void SentTimeIsLessThanMaxTime()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.MaxValue,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsFalse(returnValue);
 }
コード例 #3
0
        public void PostMessageSucceeds()
        {
            #region Setup for test
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            bool returnValue;
            repoInstance.Setup(ent => ent.Add(It.IsAny<MessagePing>())).Returns(dummyMessage);
            #endregion

            #region Test
            returnValue = testSubject.PostMessage(dummyMessage);
            repoInstance.Verify(ent => ent.Add(dummyMessage),Times.AtLeastOnce,"Was called lesser than once");
            Assert.IsTrue(returnValue);
            #endregion
        }
コード例 #4
0
 public void RecievedTimeIsAlwaysGreaterThanSentTime()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     DateTime timestamp = DateTime.UtcNow;
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = timestamp.AddMilliseconds(1),
         MessageRecievedUTC = timestamp
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsFalse(returnValue);
 }
コード例 #5
0
 public void SentTimeIsExactly1WeekInPast()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.UtcNow.AddDays(Exactly1WeekPast),
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsTrue(returnValue);
 }
コード例 #6
0
 public void IsRecievedTimeWithinPast1Hour()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.UtcNow,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsTrue(DateTime.UtcNow.AddHours(Within1HourPast) < passedToRepo.MessageRecievedUTC);
 }
コード例 #7
0
 public void IsTimeRecievedInUTCForMessage()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     DateTime timestamp = DateTime.Now;
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = timestamp,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsTrue(DateTimeKind.Utc == data.MessageRecievedUTC.Value.Kind);
 }
コード例 #8
0
 public void IsRecievedTimeBetweenMinAndMaxDateTimeValue()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.UtcNow,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsTrue(DateTime.MinValue < passedToRepo.MessageRecievedUTC &&
                     DateTime.MaxValue > passedToRepo.MessageRecievedUTC);
 }
コード例 #9
0
 public void DoesServerPreserveSentTimeForMessage()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     DateTime timestamp = DateTime.UtcNow;
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = timestamp,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.AreEqual(data.MessageSentUTC, timestamp);
 }
コード例 #10
0
 public void DoesServerAddRecievedTimeForMessage()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.UtcNow,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsNotNull(passedToRepo.MessageRecievedUTC);
 }
コード例 #11
0
 public void DoesMessageHaveMessageSentTime()
 {
     //TODO: Properly instantiate the WorkerProcess
     testSubject = new WorkerProcess(repoInstance.Object, null, null);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = DateTime.MinValue,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsFalse(returnValue);
 }
コード例 #12
0
 public void BothSentAndRecievedTimeAreNotPresent()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     MessagePing data = new MessagePing()
     {
         Id = Guid.NewGuid(),
         Source = DefaultSource,
         Destination = DefaultDestination,
         Message = "Hi!!",
         MessageSentUTC = null,
         MessageRecievedUTC = null
     };
     bool returnValue = testSubject.PostMessage(data);
     Assert.IsFalse(returnValue);
 }