private void DeleteTestSubscriber(SubscriberDto subscriber, SubscriberHelper sh)
 {
     if (subscriber != null)
     {
         try
         {
             sh.DeleteSubscriber(subscriber);
         }
         catch (System.Exception ex)
         {
             Assert.Fail(ex.Message);
         }
     }
 }
        public void MyTestInitialize()
        {
            // Helper code to get the HttpContext
            var mySIMPLTestContext = new SIMPLTestContext();
            HttpContext.Current = mySIMPLTestContext.GetHttpSession();

            // Helper Code to get the user logged into Windows
            var userName = mySIMPLTestContext.GetNameFromWindowsIdentity();

            // Calling actual production code to set the instance for this username
            CurrentUser.SetInstance(userName);

            // Calling actual production code to get the Rosettian User Object
            RosettianUser = CurrentUser.AsUserDto();

            BusinessFacadeforTests = DependencyResolver.Current.GetService<IBusinessFacade>();
            SubscriberHelperforTests = DependencyResolver.Current.GetService<SubscriberHelper>();

            // Set up the SubscriberController
            SubscriberControllerForTests = DependencyResolver.Current.GetService<SubscriberController>();
            SubscriberControllerForTests.ControllerContext = new ControllerContext(new HttpContextWrapper(HttpContext.Current), new RouteData(), SubscriberControllerForTests);
        }
        public void LoadEquipmentValidDevId()
        {
            //Arrange
            SubscriberHelper sH = new SubscriberHelper();
            SubscriberDto subscriber = sH.CreateSubscriber();
            // If you don't do this conversion, you will get the following error
            // when the MapToSubDetailsModel call is made: "Input string was not in a correct format"
            subscriber.Accounts[0].PPVPrivilege = "2";
            var model = subscriber.MapToSubDetailsModel();

            //Act
            //var model = SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber03().MapToSubDetailsModel();
            RedirectToRouteResult actionResult = SubscriberControllerForTests.LoadEquipment("MRCC30010011") as RedirectToRouteResult;

            //Assert
            Assert.IsNotNull(actionResult);
            Assert.AreEqual("Index", actionResult.RouteValues["action"]);
        }
        public void LoadLocationInvalidLocationId()
        {
            SubscriberHelper sh = new SubscriberHelper();
            SubscriberDto subscriber = null;
            try
            {
                // Arrange
                subscriber = sh.CreateMinimalSubscriberWithLocation();
                subscriber.Accounts[0].Location.ID = "4001.0001999";

                //Act
                PartialViewResult actionResult = SubscriberControllerForTests.LoadLocation(subscriber.Accounts[0].Location.ID) as PartialViewResult;

                //Assert
            Assert.IsNotNull(actionResult);
            Assert.AreEqual("Error", actionResult.ViewName);
            }
            catch (System.Exception ex)
            {
                ExceptionHelper exceptionHelper = new ExceptionHelper();
                Assert.Fail(exceptionHelper.GetAllInnerExceptionMessagesAndStackTraceForTests(ex));
            }
        }
示例#5
0
        public void CreateNotes_GetNotesFromTriad_Succeed_Test()
        {
            var loc = new LocationDto();
            var sub = new SubscriberDto();
            try
            {
                // new sub and loc data
                loc = DataHelper.NewLocationData();
                sub = DataHelper.NewSubscriberData();
                sub.Accounts.First().Location = loc;
                DataHelper.RestoreLocation1(loc, false);
                DataHelper.RestoreSubscriber1(sub, false);

                // set current subscriber
                CurrentSubscriber.SetInstance(sub);

                // create new note
                var newNote = new NoteDto
                {
                    NoteCode = "DEFAULT",
                    NoteText = "This new note is created from SIMPL integration test",
                    NoteType = NoteTypeDto.SubNote

                };
                var sh = new SubscriberHelper();
                sh.CreateSubNote(sub.ID, newNote);

                var criteria = new SearchServiceHistoryDto
                {
                    SubscriberId = sub.ID,
                    LocationId = loc.ID,
                    StartDate = DateTime.Now.AddDays(-1),
                    EndDate = DateTime.Now.AddDays(+1)
                };
                // call LoadLocation action method
                var result = NotesControllerForTests.LoadRosettianNotes(criteria);

                // validate response result is not null
                Assert.IsNotNull(result, "Notes object is null");
                Assert.IsTrue(result.Any(), "There are no notes in Triad system for the given search criteria");
                Assert.IsTrue(result.Any(x => x.Notes.Contains("This new note is created from SIMPL integration test")), "The newly created note doesn't exist");
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is AssertFailedException, ex.ToString());
                throw;
            }
            finally
            {
                DataHelper.DeleteSubscriber(sub.ID);
                DataHelper.DeleteLocation(loc.ID);
            }
        }