Inheritance: TestIncidentBase
Ejemplo n.º 1
0
        public void DeleteIncident_Test()
        {
            const string testString = "Test Test Test";

            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = _testIncidentName,
                Description = testString
            };

            _client.Create(incident);

            Assert.IsNotNull(incident.RecId);

            _client.Delete(incident);

            var incidentQuery = _client.GetQuery<TestIncident>().ForRecId(incident.RecId);
            var incidents = _client.ExecuteQuery(incidentQuery);

            Assert.AreEqual(0, incidents.Count());
        }
Ejemplo n.º 2
0
        public void GetAttachment_Test()
        {
            const string testString = "Test Test Test";
            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = _testIncidentName,
                Description = testString
            };

            _client.Create(incident);

            _client.AttachFileToObject(incident, _tmpFileList);

            var streams = _client.GetAttachmentsFromObject(incident);

            Assert.AreEqual(_client.HasAttachments(incident), streams.Count());
        }
Ejemplo n.º 3
0
        public void CreateIncident_WithNoCustomer_Test()
        {
            var incident = new TestIncident();

            _client.Create(incident);
        }
Ejemplo n.º 4
0
        public void CreateIncident_WithDefaultCustomer_Test()
        {
            const string testString = "Test Test Test";

            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = _testIncidentName,
                Description = testString
            };

            _client.Create(incident);

            Assert.IsNotNull(incident.RecId);
        }
Ejemplo n.º 5
0
        public void UpdateIncident_Description_Test()
        {
            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = _testIncidentName,
                Description = "Test Test Test"
            };

            _client.Create(incident);

            Assert.IsNotNull(incident.RecId);
            Assert.AreEqual("Test Test Test", incident.Description);

            incident.Description = "Test Updated Description";

            _client.Update(incident);

            var incidentQuery = _client.GetQuery<TestIncident>().ForRecId(incident.RecId);
            var sameIncident = _client.ExecuteQuery(incidentQuery);

            Assert.AreEqual("Test Updated Description", sameIncident.First().Description);

            _client.Delete(incident);
        }
Ejemplo n.º 6
0
        public void UpdateIncident_WithValidatorValidation_Test()
        {
            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = _testIncidentName,
                Description = "Test Test Test"
            };

            _client.Create(incident);

            Assert.IsNotNull(incident.RecId);
            Assert.AreEqual("Test Test Test", incident.Description);

            incident.Title = "throw exception";
            var threwException = false;

            try
            {
                _client.Update(incident);
            }
            catch (CsmValidationException e)
            {
                threwException = true;
            }

            Assert.IsTrue(threwException);
            _client.Delete(incident);
        }
Ejemplo n.º 7
0
        public void UpdateIncident_UpdateFails_UpdateIsRolledBack()
        {
            var testTitle = "Test Incident 2";
            var incident = new TestIncident
            {
                CustomerId = _defaultCustomerId,
                Title = testTitle,
                Description = "Test Test Test"
            };

            _client.Create(incident);

            Assert.IsNotNull(incident.RecId);
            Assert.AreEqual("Test Test Test", incident.Description);

            incident.Description = "Changed Test";
            incident.Title = "throw exception";

            try
            {
                _client.Update(incident);
            }
            catch
            {
                // Swallow the exception so we can confirm that our updates were rolled back
            }

            var readIncident =
                _client.ExecuteQuery(_client.GetQuery<TestIncident>().Where(x => x.Title == testTitle)).Single();
            Assert.AreEqual("Test Test Test", readIncident.Description);
            _client.Delete(incident);
        }