public void GetActiveHelpdesks()
        {
            var factory = new TestEntityFactory();

            var hd1 = factory.AddHelpdesk(AlphaNumericStringGenerator.GetString(10));
            var hd2 = factory.AddHelpdesk(AlphaNumericStringGenerator.GetString(10));

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                var helpdesk = context.Helpdesksettings.FirstOrDefault(hd => hd.HelpdeskId == hd2.Response.HelpdeskID);

                helpdesk.IsDeleted = true;
                context.SaveChanges();
            }

            var facade   = new HelpdeskFacade();
            var response = facade.GetActiveHelpdesks();

            Assert.AreEqual(HttpStatusCode.OK, response.Status);
            Assert.IsTrue(response.Helpdesks.Count > 0);

            List <int> helpdeskIds = response.Helpdesks.Select(hd => hd.HelpdeskID).ToList();

            Assert.IsTrue(helpdeskIds.Contains(hd1.Response.HelpdeskID));
            Assert.IsTrue(!helpdeskIds.Contains(hd2.Response.HelpdeskID));
        }
        public void AddUnit()
        {
            // Fill empty string parameters "" with auto-generated string.
            testEntityFactory.PopulateEmptyStrings = true;

            // Add test helpdesk.
            TestDataHelpdesk helpdeskData = testEntityFactory.AddHelpdesk();

            // Check that helpdesk was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, helpdeskData.Response.Status);
            Assert.IsTrue(helpdeskData.Response.HelpdeskID > 0);

            // Create a unit. ID provided is 0, which will indicates creation of new helpdesk.
            List <string> topics   = new List <string>(new string[] { "Layouts", "Lifecycle" });
            TestDataUnit  unitData = testEntityFactory.AddUpdateUnit(0, helpdeskData.Response.HelpdeskID, "", "", false, topics);

            // Check that unit was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, unitData.Response.Status);
            Assert.IsTrue(unitData.Response.UnitID > 0);

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                int confirmId = unitData.Response.UnitID;
                var unit      = context.Unit.Include("Topic").FirstOrDefault(u => u.UnitId == confirmId);
                Assert.IsNotNull(unit);
                Assert.IsTrue
                (
                    unitData.Request.IsDeleted == unit.IsDeleted &&
                    unitData.Request.Name == unit.Name &&
                    unitData.Request.Code == unit.Code &&
                    unitData.Request.Topics.Count + 1 == unit.Topic.Count &&
                    unit.Topic.Count > 0
                );
            }
        }
        public void UpdateQueueItem()
        {
            // Fill empty string parameters "" with auto-generated string.
            testEntityFactory.PopulateEmptyStrings = true;

            // Add test helpdesk.
            TestDataHelpdesk helpdeskData = testEntityFactory.AddHelpdesk();

            // Check that helpdesk was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, helpdeskData.Response.Status);
            Assert.IsTrue(helpdeskData.Response.HelpdeskID > 0);

            // Create a unit. ID provided is 0, which will indicates creation of new helpdesk.
            List <string> topics   = new List <string>(new string[] { "Layouts", "Lifecycle" });
            TestDataUnit  unitData = testEntityFactory.AddUpdateUnit(0, helpdeskData.Response.HelpdeskID, "", "", false, topics);

            // Check that unit was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, unitData.Response.Status);
            Assert.IsTrue(unitData.Response.UnitID > 0);

            // Get topics for the unit that was just created.
            TopicsFacade topicsFacade = new TopicsFacade();
            GetTopicsByUnitIDResponse topicResponse = topicsFacade.GetTopicsByUnitID(unitData.Response.UnitID);

            // Check that there are two units in the response (Layouts, Lifecycle).
            Assert.IsTrue(topicResponse.Topics.Count() == 3);

            // Add test queue item, pass in topic [0].
            TestDataQueue queueData = testEntityFactory.AddQueueItem(null, topicResponse.Topics[0].TopicId);

            // Check that queue item was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, queueData.Response.Status);

            // Create request to alter queue item.
            var queueUpdateRequest = new UpdateQueueItemRequest
            {
                TopicID     = topicResponse.Topics[0].TopicId,
                Description = "UpdateQueueItem Test"
            };

            // Update the queue item
            UpdateQueueItemResponse updateQueueResponse = testEntityFactory.QueueFacade.UpdateQueueItem(queueData.Response.ItemId, queueUpdateRequest);

            // Check that queue item was updated successfully.
            Assert.AreEqual(HttpStatusCode.OK, updateQueueResponse.Status);

            // Do another request to change to another topic
            queueUpdateRequest = new UpdateQueueItemRequest
            {
                TopicID     = topicResponse.Topics[1].TopicId,
                Description = "UpdateQueueItem Test 2"
            };

            // Update the queue item again
            updateQueueResponse = testEntityFactory.QueueFacade.UpdateQueueItem(queueData.Response.ItemId, queueUpdateRequest);

            // Check that queue item was updated successfully.
            Assert.AreEqual(HttpStatusCode.OK, updateQueueResponse.Status);
        }
예제 #4
0
        public void GetTopicsByUnitID()
        {
            // Fill empty string parameters "" with auto-generated string.
            testEntityFactory.PopulateEmptyStrings = true;

            // Add test helpdesk.
            TestDataHelpdesk helpdeskData = testEntityFactory.AddHelpdesk();

            // Check that helpdesk was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, helpdeskData.Response.Status);
            Assert.IsTrue(helpdeskData.Response.HelpdeskID > 0);

            // Create a unit. ID provided is 0, which will indicates creation of new helpdesk.
            List <string> topics   = new List <string>(new string[] { "Layouts", "Lifecycle" });
            TestDataUnit  unitData = testEntityFactory.AddUpdateUnit(0, helpdeskData.Response.HelpdeskID, "", "", false, topics);

            // Check that unit was created successfully.
            Assert.AreEqual(HttpStatusCode.OK, unitData.Response.Status);
            Assert.IsTrue(unitData.Response.UnitID > 0);

            // Get all topics associated with the unit id.
            var topicsFacade = new TopicsFacade();
            GetTopicsByUnitIDResponse topicResponse = topicsFacade.GetTopicsByUnitID(unitData.Response.UnitID);

            // Check that the topics retrieved are correct.
            Assert.AreEqual(HttpStatusCode.OK, unitData.Response.Status);
            Assert.IsTrue(topicResponse.Topics.Count == 3);
        }
        public void GetHelpdesks()
        {
            var factory = new TestEntityFactory();

            var data = factory.AddHelpdesk(AlphaNumericStringGenerator.GetString(10));

            var facade   = new HelpdeskFacade();
            var response = facade.GetHelpdesks();

            Assert.AreEqual(HttpStatusCode.OK, response.Status);
            Assert.IsTrue(response.Helpdesks.Count > 0);
        }
        public void GetHelpdeskSuccess()
        {
            var factory = new TestEntityFactory();

            var data = factory.AddHelpdesk(AlphaNumericStringGenerator.GetString(10));

            var facade   = new HelpdeskFacade();
            var response = facade.GetHelpdesk(data.Response.HelpdeskID);

            Assert.AreEqual(HttpStatusCode.OK, response.Status);
            Assert.IsNotNull(response.Helpdesk);
        }
        public void AddHelpdesk()
        {
            testEntityFactory.PopulateEmptyStrings = true;

            TestDataHelpdesk testEntityData = testEntityFactory.AddHelpdesk();

            Assert.AreEqual(HttpStatusCode.OK, testEntityData.Response.Status);
            Assert.IsTrue(testEntityData.Response.HelpdeskID > 0);

            using (helpdesksystemContext context = new helpdesksystemContext())
            {
                var helpdesk = context.Helpdesksettings.FirstOrDefault(p => p.HelpdeskId == testEntityData.Response.HelpdeskID);

                Assert.IsNotNull(helpdesk);
            }
        }