コード例 #1
0
        public void TestTryToAddPeopleWhenUserIsNotFound1()
        {
            #region Arrange
            new FakeUsers(0, UserRepository);
            SearchService.Expect(a => a.FindUser(Arg <string> .Is.Anything)).Return(null);
            var failCount = 0;
            var dupCount  = 0;
            var notAdded  = new List <KeyValuePair <string, string> >();
            #endregion Arrange

            #region Act
            var result = WorkgroupService.TryToAddPeople(1, new Role(), new Workgroup(), 0, "test", ref failCount, ref dupCount, notAdded);
            #endregion Act

            #region Assert
            UserRepository.AssertWasCalled(a => a.GetNullableById("test"));
            SearchService.AssertWasCalled(a => a.FindUser("test"));
            Assert.AreEqual(1, failCount);
            Assert.AreEqual(0, dupCount);
            Assert.AreEqual(0, result);
            Assert.AreEqual(1, notAdded.Count());
            Assert.AreEqual("Not found", notAdded[0].Value);
            Assert.AreEqual("test", notAdded[0].Key);
            #endregion Assert
        }
コード例 #2
0
        public void TestFindPersonReturnsExpectedResult()
        {
            #region Arrange
            var directoryUser = new DirectoryUser();
            directoryUser.LoginId      = "someLogin";
            directoryUser.EmailAddress = "*****@*****.**";
            directoryUser.LastName     = "SomeLast";
            directoryUser.FirstName    = "SomeFirst";
            DirectorySearchService.Expect(a => a.FindUser("Test")).Return(directoryUser);
            #endregion Arrange

            #region Act
            var result = Controller.FindPerson("Test")
                         .AssertResultIs <JsonNetResult>();
            #endregion Act

            #region Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("{\"EmployeeId\":null,\"LoginId\":\"someLogin\",\"FirstName\":\"SomeFirst\",\"LastName\":\"SomeLast\",\"FullName\":null,\"EmailAddress\":\"[email protected]\",\"PhoneNumber\":null}", result.JsonResultString);
            DirectorySearchService.AssertWasCalled(a => a.FindUser("Test"));
            #endregion Assert
        }