Ejemplo n.º 1
0
        public void ACTDetailsExtResponseToActivityModel_MappingTest_Valid()
        {
            //1. setup data
            var source = ActivityTestDataHelper.CreateDummyACTDetailsExResponse();

            //2. Exec
            var dest = MappingEngine.Map <ActivityModel>(source);

            //3. Verification
            Assert.AreEqual(source.ActivityName, dest.ActivityName);
            Assert.AreEqual(source.ActivityDescription, dest.ActivityDescription);
            Assert.AreEqual(source.ActivityType, dest.ActivityType);
            Assert.AreEqual(source.SubType, dest.SubType);
            Assert.AreEqual(source.OrgCode, dest.OrgCode);
            Assert.AreEqual(source.SiteCode, dest.SiteCode);
            Assert.AreEqual(source.StartDate, dest.StartDate);
            Assert.AreEqual(source.EndDate, dest.EndDate);
            Assert.AreEqual(source.Status, dest.Status);
            Assert.AreEqual(source.IndustryCode.Length, dest.IndustryCodes.Length);
            Assert.AreEqual(source.RelatedActivityIds.Length, dest.RelatedActivityIds.Length);
            //flag
            Assert.AreEqual(source.IntegrityControlNumber, dest.IntegrityControlNumber);
            //Check location
            Assert.AreEqual(source.LocOrganisationName, dest.RelatedInfo.Location.HostName);
            //Check host
            Assert.AreEqual(source.HostOrganisationName, dest.RelatedInfo.HostLink.Host.HostName);
        }
        public void ListLocations_Valid()
        {
            //1. Setup data
            //a.request
            long activityId = 123123;

            //b.response
            List <LocationDetails> list = new List <LocationDetails>();

            for (int i = 1; i < 10; i++)
            {
                list.Add(ActivityTestDataHelper.CreateDummyACTLocDetails(i));
            }

            var response = new ACTLocSearchResponse()
            {
                Locations = list.ToArray()
            };

            mockActivityHostLocationtWcf.Setup(m => m.GetLocationList(It.IsAny <ACTLocSearchRequest>())).Returns(response);

            //2. Exec service
            var result = SystemUnderTest().ListLocations(activityId);

            //3. Verification
            Assert.AreEqual("Test 1231", result.ElementAt(0).HostName);
            Assert.AreEqual("2345", result.ElementAt(0).ESA);

            //Verify behaviour
            mockActivityHostLocationtWcf.Verify(m => m.GetLocationList(It.Is <ACTLocSearchRequest>(r => r.ActivityId == activityId)), Times.Once());
        }
Ejemplo n.º 3
0
        public void ACTSearchResponseToActivitySearchModel_MappingTest_Valid()
        {
            //1. setup data
            List <ACTList> actLists = new List <ACTList>();

            for (int i = 1; i < 10; i++)
            {
                actLists.Add(ActivityTestDataHelper.CreateDummyACTList(i));
            }

            var source = new ACTSearchResponse
            {
                MoreDataflag          = "Y",
                NextActivityId        = 123123,
                NextActivityStartDate = DateTime.Today,
                actLists = actLists.ToArray(),
            };

            //2. Exec
            var dest = MappingEngine.Map <ActivityListModel>(source);

            //3. Verification
            //Verify More parameters
            Assert.AreEqual(true, dest.HasMoreRecords);
            Assert.AreEqual(source.NextActivityId, dest.StartActivityId);
            Assert.AreEqual(source.NextActivityStartDate, dest.StartActivityStartDate);
            //Verify response list
            Assert.AreEqual(source.actLists.Length, dest.Results.Count());
        }
        public void ListHostLinks_Valid()
        {
            //public ACTHostListResponse GetHostList(ACTHostListRequest hostListRequest)
            //1. Setup data
            //a.request
            long activityId = 123123;

            //b.response
            List <ACTHostList> list = new List <ACTHostList>();

            for (int i = 1; i < 10; i++)
            {
                list.Add(ActivityTestDataHelper.CreateDummyACTHostList(i));
            }

            var response = new ACTHostListResponse()
            {
                hostLists = list.ToArray()
            };

            mockActivityHostLocationtWcf.Setup(m => m.GetHostList(It.IsAny <ACTHostListRequest>())).Returns(response);

            MappingEngine.Map <IEnumerable <ActivityHostLinkModel> >(response.hostLists);

            //2. Exec service
            var result = SystemUnderTest().ListHostLinks(activityId);

            //3. Verification
            Assert.AreEqual(1, result.ElementAt(0).HostId);
            Assert.AreEqual(1, result.ElementAt(0).Host.HostID);
            //Verify behaviour
            mockActivityHostLocationtWcf.Verify(m => m.GetHostList(It.Is <ACTHostListRequest>(r => r.ActivityId == activityId)), Times.Once());
        }
        public void SearchLocations_WcfThrowsFaultException_ThrowsServiceValidationException()
        {
            var exception = ActivityTestDataHelper.CreateDummyFaultException();

            //1. Setup data
            //a.request
            mockActivityHostLocationtWcf.Setup(m => m.GetLocationList(It.IsAny <ACTLocSearchRequest>())).Throws(exception);

            //2. exec
            var result = SystemUnderTest().ListLocations(123);
        }
Ejemplo n.º 6
0
        public void ACTListToActivityModel_MappingTest_Valid()
        {
            //1. setup data
            var source = ActivityTestDataHelper.CreateDummyACTList(8);

            //2. Exec
            var dest = MappingEngine.Map <ActivityModel>(source);

            //3. Verification
            Assert.AreEqual(source.ActivityId, dest.ActivityId);
            Assert.AreEqual(source.TitleText, dest.ActivityName);
        }
        public void Get_WcfThrowsFaultException_ThrowsServiceValidationException()
        {
            var exception = ActivityTestDataHelper.CreateDummyFaultException();

            //1. Setup data
            //a.request
            long activityId = 12313123;

            mockActivityManagementWcf.Setup(m => m.GetActivityDetailsEx(It.IsAny <ACTDetailsRequest>())).Throws(exception);

            //2. exec
            var result = SystemUnderTest().GetActivitity(activityId);
        }
        public void List_WcfThrowsFaultException_ThrowsServiceValidationException()
        {
            var exception = ActivityTestDataHelper.CreateDummyFaultException();

            //1. Setup data
            //a.request
            var request = ActivityTestDataHelper.CreateDummyActivityListModel();

            mockActivityManagementWcf.Setup(m => m.GetActivityList(It.IsAny <ACTSearchRequest>())).Throws(exception);

            //2. exec
            var result = SystemUnderTest().ListActivities(request);
        }
        public void GetLocation_WcfThrowsFaultException_ThrowsServiceValidationException()
        {
            var exception = ActivityTestDataHelper.CreateDummyFaultException();

            //1. Setup data
            //a.request
            long activityId        = 123;
            long locationSeqNumber = 1;

            mockActivityHostLocationtWcf.Setup(m => m.GetLocationDetails(It.IsAny <ACTGetLocDetailsRequest>())).Throws(exception);

            //2. exec
            var result = SystemUnderTest().GetLocation(activityId, locationSeqNumber);
        }
Ejemplo n.º 10
0
        public void ACTDetailsExtResponseToActivityModel_MappingTest_WithoutHostAndLocation()
        {
            //1. setup data
            var source = ActivityTestDataHelper.CreateDummyACTDetailsExResponse();

            source.LocSeqNum = 0;
            source.HostId    = 0;
            //2. Exec
            var dest = MappingEngine.Map <ActivityModel>(source);

            //3. Verification
            //Check location
            Assert.IsNull(dest.RelatedInfo.Location);
            //Check host
            Assert.IsNull(dest.RelatedInfo.HostLink);
        }
        public void UpdateLocation_Valid()
        {
            //1. Setup data
            //a.request
            var request = ActivityTestDataHelper.CreateDummyActivityLocationModel();

            var response = new ACTManageLocationResponse();

            response.INTControlNumber = request.IntegrityControlNumber + 1;

            mockActivityHostLocationtWcf.Setup(m => m.ManageLocation(It.IsAny <ACTManageLocationRequest>())).Returns(response);

            //2. Exec service
            var result = SystemUnderTest().UpdateLocation(request);

            //3. Verification
            Assert.AreEqual(result.IntegrityControlNumber, response.INTControlNumber);
        }
Ejemplo n.º 12
0
        public void List_FailedResponse_ThrowsServiceValidationException()
        {
            //1. Setup data
            //a.request
            var request = ActivityTestDataHelper.CreateDummyActivityListModel();

            //b.response
            var response = new ACTSearchResponse();

            response.ExecutionResult = ActivityTestDataHelper.CreateDummyFailedExecutionResult();

            mockActivityManagementWcf.Setup(m => m.GetActivityList(It.IsAny <ACTSearchRequest>())).Returns(response);

            //2. exec
            var result = SystemUnderTest().ListActivities(request);

            //3. Verification
        }
        public void GetHost_Valid()
        {
            //ACTGetHostDetailsResponse GetHostDetails(ACTGetHostDetailsRequest getHostRequest)
            //1. Setup data
            //a.request
            long hostId = 123123;

            var response = ActivityTestDataHelper.CreateDummyACTGetHostDetailsResponse();

            mockActivityHostLocationtWcf.Setup(m => m.GetHostDetails(It.IsAny <ACTGetHostDetailsRequest>())).Returns(response);

            //2. Exec service
            var result = SystemUnderTest().GetHost(hostId);

            //3. Verification
            Assert.AreEqual("Test123", result.HostName);
            Assert.AreEqual("Line1", result.AddressLine1);
            Assert.AreEqual("Line2", result.AddressLine2);
            Assert.AreEqual("Line3", result.AddressLine3);
        }
        public void AddLocation_Valid()
        {
            //1. Setup data
            //a.request
            var request = ActivityTestDataHelper.CreateDummyActivityLocationModel();

            request.IntegrityControlNumber = 0; // Use the same WCF service as Update, use the ICN to tell whether it is add or update

            var response = new ACTManageLocationResponse();

            response.LocationSeqNumber = 123;

            mockActivityHostLocationtWcf.Setup(m => m.ManageLocation(It.IsAny <ACTManageLocationRequest>())).Returns(response);

            //2. Exec service
            var result = SystemUnderTest().AddLocation(request);

            //3. Verification
            Assert.AreEqual(result, response.LocationSeqNumber);
        }
Ejemplo n.º 15
0
        public void ActivitySearchModelToACTSearchRequest_MappingTest_Valid()
        {
            //1. setup data
            var source = ActivityTestDataHelper.CreateDummyActivityListModel();

            //2. Exec
            var dest = MappingEngine.Map <ACTSearchRequest>(source);

            //3. Verification
            Assert.AreEqual(source.SearchType, dest.SearchType);
            Assert.AreEqual(source.ActivityType, dest.ActivityType);
            Assert.AreEqual(source.SubType, dest.SubType);
            Assert.AreEqual(source.OrgCode, dest.OrgCode);
            Assert.AreEqual(source.SiteCode, dest.SiteCode);
            Assert.AreEqual(source.ESACode, dest.ESACode);
            Assert.AreEqual(source.Status, dest.ActivityStatus);
            Assert.AreEqual(source.FromPostCode, dest.FromPostCode);
            Assert.AreEqual(source.StartActivityId, dest.StartActivityId);
            Assert.AreEqual(source.StartActivityStartDate, dest.StartActivityStartDate);
        }
Ejemplo n.º 16
0
        public void Get_Valid()
        {
            //1. Setup data
            //a.request
            long activityId = 12313123;
            //b.response
            var response = ActivityTestDataHelper.CreateDummyACTDetailsExResponse();

            mockActivityManagementWcf.Setup(m => m.GetActivityDetailsEx(It.IsAny <ACTDetailsRequest>())).Returns(response);

            //2. exec
            var result = SystemUnderTest().GetActivitity(activityId);

            //3. Verification
            //Verify More parameters
            Assert.AreEqual(activityId, result.ActivityId);
            Assert.AreEqual(response.ActivityName, result.ActivityName);
            //No need to verify other attributes, it is tested by the mapping tests

            //Verify behaviour
            mockActivityManagementWcf.Verify(m => m.GetActivityDetailsEx(It.Is <ACTDetailsRequest>(r => r.ActivityId == activityId)), Times.Once());
        }
Ejemplo n.º 17
0
        public void List_Valid()
        {
            //1. Setup data
            //a.request
            var request = ActivityTestDataHelper.CreateDummyActivityListModel();
            //b.response
            List <ACTList> actLists = new List <ACTList>();

            for (int i = 1; i < 10; i++)
            {
                actLists.Add(ActivityTestDataHelper.CreateDummyACTList(i));
            }

            var response = new ACTSearchResponse
            {
                MoreDataflag          = "Y",
                NextActivityId        = 123123,
                NextActivityStartDate = DateTime.Today,
                actLists = actLists.ToArray(),
            };

            mockActivityManagementWcf.Setup(m => m.GetActivityList(It.IsAny <ACTSearchRequest>())).Returns(response);

            //2. exec
            var result = SystemUnderTest().ListActivities(request);

            //3. Verification
            //Verify More parameters
            Assert.AreEqual(true, result.HasMoreRecords);
            Assert.AreEqual(response.NextActivityId, result.StartActivityId);
            Assert.AreEqual(response.NextActivityStartDate, result.StartActivityStartDate);
            //Verify response list
            Assert.AreEqual(response.actLists.Length, result.Results.Count());

            //Verify behaviour
            mockActivityManagementWcf.Verify(m => m.GetActivityList(It.Is <ACTSearchRequest>(r => r.SearchType == request.SearchType)), Times.Once());
        }