public void Equals()
        {
            StringTaskSummary summary = new StringTaskSummary("Hello World");

            Assert.IsTrue(summary.Equals(summary));
            Assert.IsFalse(summary.Equals(default(StringTaskSummary)));
            Assert.IsTrue(summary.Equals(new StringTaskSummary("Hello World")));
            Assert.IsFalse(summary.Equals(new StringTaskSummary("Hello Summary")));

            Assert.IsFalse(summary.Equals(default(string)));
            Assert.IsFalse(summary.Equals(string.Empty));
            Assert.IsTrue(summary.Equals("Hello World"));
            Assert.IsFalse(summary.Equals("Hello Summary"));

            Assert.IsTrue(summary.Equals((object)summary));
            Assert.IsFalse(summary.Equals((object)default(StringTaskSummary)));
            Assert.IsTrue(summary.Equals((object)new StringTaskSummary("Hello World")));
            Assert.IsFalse(summary.Equals((object)new StringTaskSummary("Hello Summary")));

            Assert.IsFalse(summary.Equals((object)default(string)));
            Assert.IsFalse(summary.Equals((object)string.Empty));
            Assert.IsTrue(summary.Equals((object)"Hello World"));
            Assert.IsFalse(summary.Equals((object)"Hello Summary"));

            Assert.IsFalse(summary.Equals(1));
        }
        public void ImplicitSummaryToString()
        {
            Assert.IsNull((string)default(StringTaskSummary));

            string s = new StringTaskSummary("Hello World");

            Assert.AreEqual("Hello World", s);
        }
        public void Add()
        {
            Guid taskId = Guid.NewGuid();

            StringTaskSummary summary1 = new StringTaskSummary("Hello World");

            this.Repository.Add(taskId, summary1);

            StringTaskSummary summary2 = (StringTaskSummary)this.Repository.GetById(taskId);

            Assert.AreEqual(summary1.Summary, summary2.Summary);
        }
Exemplo n.º 4
0
 protected override void AssertAreEqual(StringTaskSummary first, StringTaskSummary second)
 {
     Assert.AreEqual(first.Summary, second.Summary);
 }
Exemplo n.º 5
0
 protected override void AssertIsEmpty(StringTaskSummary summary)
 {
     Assert.IsTrue(string.IsNullOrEmpty(summary.Summary));
 }
        public void Constructor()
        {
            StringTaskSummary summary1 = new StringTaskSummary("Hello World");

            Assert.AreEqual("Hello World", summary1.Summary);
        }
        public void ImplicitStringToSummary()
        {
            StringTaskSummary summary = "Hello World";

            Assert.AreEqual("Hello World", summary.Summary);
        }
        public void ImplicitEmptyStringToSummary()
        {
            StringTaskSummary summary = string.Empty;

            Assert.IsTrue(string.IsNullOrEmpty(summary.Summary));
        }
        public void ImplicitNullStringToSummary()
        {
            StringTaskSummary summary = default(string);

            Assert.IsNull(summary.Summary);
        }
Exemplo n.º 10
0
        private void SubmitTask(bool isPollingQueueTask, bool hasSummary, TaskPriority expectedPriority, Func <ITask, ITaskSummary, Guid> submitCallback)
        {
            this.DateTimeProvider.UtcNow = DateTime.UtcNow.AddMinutes(-1);

            FakeTask task1 = new FakeTask()
            {
                StringValue = "Hello Submit Task",
                NumberValue = 1234567
            };

            StringTaskSummary summary1;

            if (hasSummary)
            {
                summary1 = new StringTaskSummary("Hello World");
            }

            this.Configuration.PredefineResult(isPollingQueueTask ? "Test" : null, c => c.GetPollingQueueKey(task1.GetType()));

            Guid taskId = submitCallback(task1, summary1);

            Assert.IsNotNull(this.TaskProcessorFacade.GetTask(taskId));

            ITaskRuntimeInfo taskInfo = this.TaskProcessorFacade.GetTaskRuntimeInfo(taskId);

            Assert.IsNotNull(taskInfo);

            Assert.AreEqual(taskId, taskInfo.TaskId);
            Assert.AreEqual(expectedPriority, taskInfo.Priority);
            Assert.AreEqual(TaskStatus.Pending, taskInfo.Status);
            Assert.AreEqual(this.DateTimeProvider.UtcNow, taskInfo.SubmittedUtc);

            FakeTask task2 = (FakeTask)this.Repository.Tasks.GetById(taskId);

            UnitTestHelpers.AssertEqualByPublicScalarProperties(task1, task2);

            if (hasSummary)
            {
                StringTaskSummary summary2 = (StringTaskSummary)this.Repository.TaskSummary.GetById(taskId);

                Assert.AreEqual(summary1.Summary, summary2.Summary);
            }

            TaskSubmittedMasterCommand message = this.TaskProcessorFacade.MessageBus.MasterCommands
                                                 .OfType <TaskSubmittedMasterCommand>()
                                                 .SingleOrDefault(m => m.TaskId == taskId);

            if (isPollingQueueTask)
            {
                Assert.IsNull(message);

                Assert.IsTrue(this.Repository.TaskRuntimeInfo.GetPending(true).Any(p => p.TaskId == taskId));
                Assert.IsTrue(this.Repository.TaskRuntimeInfo.ReservePollingQueueTasks("Test", int.MaxValue).Any(p => p.TaskId == taskId));
            }
            else
            {
                Assert.IsNotNull(message);

                Assert.AreNotEqual(Guid.Empty, message.MessageUniqueId);
                Assert.AreEqual(taskId, message.TaskId);

                Assert.IsTrue(this.Repository.TaskRuntimeInfo.GetPending(false).Any(p => p.TaskId == taskId));
            }
        }