示例#1
0
        public void WhenThereisNoPersonInfoInStoredTable_thenShouldCallTheAPIForGettingTheUserInfo()
        {
            PersonLocalStorageMock.Setup(x => x.FindPersonAsync(It.IsAny <ExternalId>()))
            .Returns(Task.FromResult <Person>(null));
            ContextMappingLocalStorage.Setup(x => x.Resolve(It.IsAny <string>())).Returns(
                "http://we-d-app-youforce-ext-resolver.azurewebsites.net/api/persons/{id}/personaldetails");
            RestSharpHelper.Setup(e => e.Get <Person>(It.IsAny <RestSharpParams>())).Returns(GetRandomPersonData());
            var userInfo = new UserInformation(PersonLocalStorageMock.Object, ContextMappingLocalStorage.Object,
                                               RestSharpHelper.Object);
            var result = userInfo.GetUsers(new List <ExternalId>
            {
                ExternalIdMockInfoUser1,
                ExternalIdMockInfoUser2
            });

            Assert.True(result.ToList().Count == 2);
        }
示例#2
0
        public void WhenThereisValidPersonInfoInStoredTable_thenShouldFetchTheDataFromTheUserInfoTable()
        {
            var personalInfoMock = new PersonalInfo
            {
                BirthDate = DateTime.Today, Initials = "S", LastNameAtBirth = "A", LastNameAtBirthPrefix = "B"
            };

            PersonLocalStorageMock.Setup(x => x.FindPersonAsync(It.Is <ExternalId>(y => y.Id == "IC12345")))
            .Returns(Task.FromResult(new Person(ExternalIdMockInfoUser1, personalInfoMock)));
            var userInfo = new UserInformation(PersonLocalStorageMock.Object, ContextMappingLocalStorage.Object, RestSharpHelper.Object);
            var result   = userInfo.GetUsers(new List <ExternalId>
            {
                ExternalIdMockInfoUser1
            });

            Assert.True(result.ToList().Count == 1);
            Assert.Equal(result.First().PersonalInfo.Initials, personalInfoMock.Initials);
            Assert.Equal(result.First().PersonalInfo.LastNameAtBirth, personalInfoMock.LastNameAtBirth);
            Assert.Equal(result.First().PersonalInfo.LastNameAtBirthPrefix, personalInfoMock.LastNameAtBirthPrefix);
        }