Esempio n. 1
0
        public void TestConnection_WhenGivenValidCredentials_ShouldSuccessfullyEstablishAConnection()
        {
            // ARRANGE
            var stubRepo = Substitute.For <IRestRepository>();

            stubRepo.Credentials = Arg.Any <Credentials>();

            var header = new Header()
            {
                ContentType = "application/json"
            };
            var session = new Session()
            {
                UserName       = "******",
                Password       = "******",
                Authentication = "CCM"
            };

            stubRepo.TestConnection(session).Returns(true);

            var mockBehavior = new TestConnectionBehavior(_userToken, stubRepo);

            mockBehavior.Session = session;

            // ACT
            var result = mockBehavior.TestConnection("fooServiceUrl", "validUsername", "validPassword", "barFacility");

            // ASSERT
            Assert.AreEqual(true, mockBehavior.ConnectionEstablished);
        }
Esempio n. 2
0
        public void TestConnection_WhenGivenValidCredentials_ShouldEstablishConnectivityWithCCM()
        {
            // ARRANGE
            _app.IsAddon = true;

            var credentials = new Credentials()
            {
                BaseUrl  = "https://some.bank.or.cu/api",
                Username = "******",
                Password = "******",
                Facility = "validFacility"
            };

            var credentialsHeader = GetCredentialsHeader(credentials);

            var messageXml = _person.Message?.SerializeToXmlString();

            messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                messageXml,
                _app.HostValues.Where(hv => hv.Field1.StartsWith("UpdatePerson.")).ToList(),
                _person.Message?.HostValueParentNode
                );

            var processMessageNodeRequest = new ProcessMessageNodeRequest()
            {
                CredentialsHeader = credentialsHeader,
                request           = GetXmlNode(messageXml)
            };

            var stubServiceRepo = Substitute.For <ISoapRepository>();

            stubServiceRepo.GetProcessMessageNodeRequest(credentialsHeader, messageXml).Returns(processMessageNodeRequest);

            _messageResponse = GetMessageResponseSystemMalfunction();

            stubServiceRepo.UpdatePerson(_person, _app).Returns(_messageResponse);

            var mockBehavior = new TestConnectionBehavior(_app, _userToken, stubServiceRepo);

            mockBehavior.Person = _person;

            // ACT
            var result = mockBehavior.TestConnection("fooServiceUrl", "barUserName", "fooPassword", "barFacility");

            // ASSERT
            Assert.IsTrue(result.Result);
            Assert.AreEqual("SystemMalfunction", mockBehavior.MessageResponse.ResponseCode);
            Assert.AreEqual("Modify Party request failed. Party 99999999 not found.", mockBehavior.MessageResponse.ErrorMessage);
            Assert.IsTrue(mockBehavior.ConnectionEstablished);
        }
Esempio n. 3
0
        public void TestConnection_WhenCalled_ShouldCallRepositoryTestConnection()
        {
            // ARRANGE
            var mockRepo = Substitute.For <IRestRepository>();

            mockRepo.Credentials = _credentials;
            var stubBehavior = new TestConnectionBehavior(_userToken, mockRepo);


            // ACT
            var dontCare = stubBehavior.TestConnection("fooServiceUrl", "barUserName", "fooPassword", "barFacility");

            // ASSERT
            mockRepo.Received().TestConnection(Arg.Any <Session>());
        }
Esempio n. 4
0
        public void TestConnection_WhenCalled_ShouldCallRepositoryUpdatePerson()
        {
            // ARRANGE
            var messageResponse = new MessageResponse()
            {
                ErrorMessage = "CardNotFound"
            };

            var stubRepo = Substitute.For <ISoapRepository>();

            stubRepo.UpdatePerson(Arg.Any <UpdatePerson>(), Arg.Any <Application>()).Returns(messageResponse);

            var mockBehavior = new TestConnectionBehavior(_app, "userToken123", stubRepo);

            // ACT
            var dontCare = mockBehavior.TestConnection("fooServiceUrl", "barUserName", "fooPassword", "barFacility");

            // ASSERT
            mockBehavior.SoapRepository.Received().UpdatePerson(Arg.Any <UpdatePerson>(), Arg.Any <Application>());
        }
Esempio n. 5
0
 /// <summary>
 /// Tests the connection to a CCM service.
 /// </summary>
 /// <param name="serviceUrl"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <param name="facility"></param>
 /// <returns></returns>
 public virtual BaseResult TestConnection(string serviceUrl, string userName, string password, string facility)
 {
     return(TestConnectionBehavior.TestConnection(serviceUrl, userName, password, facility));
 }