Example #1
0
        public void TestSave_serverSourceNotNull()
        {
            //arrange
            var expectedAuthenticationType = AuthenticationType.User;
            var expectedServerName         = "someServerName";
            var expectedPassword           = "******";
            var expectedUserName           = "******";

            var sourceName = "someSourceName";

            var expectedHeaderText = sourceName;
            var expectedHeader     = sourceName + " *";

            _sharepointServerSourceMock.Setup(it => it.Name).Returns(sourceName);

            _targetSource.AuthenticationType = expectedAuthenticationType;
            _targetSource.Password           = expectedPassword;
            _targetSource.UserName           = expectedUserName;
            _targetSource.ServerName         = expectedServerName;

            //act
            _targetSource.Save();

            //assert
            Assert.AreSame(_sharepointServerSourceMock.Object, _targetSource.Item);
            _sharepointServerSourceMock.VerifySet(it => it.AuthenticationType = expectedAuthenticationType);
            _sharepointServerSourceMock.VerifySet(it => it.Server             = expectedServerName);
            _sharepointServerSourceMock.VerifySet(it => it.Password           = expectedPassword);
            _sharepointServerSourceMock.VerifySet(it => it.UserName           = expectedUserName);
            Assert.AreEqual(expectedHeaderText, _targetSource.HeaderText);
            Assert.AreEqual(expectedHeader, _targetSource.Header);
            _updateManagerMock.Verify(it => it.Save(_sharepointServerSourceMock.Object));
        }
Example #2
0
        public void SharepointServerSourceTestSave()
        {
            //arrange
            var sourceMock = new Mock <ISharepointServerSource>();

            //act
            _target.Save(sourceMock.Object);

            //assert
            _updateManagerMock.Verify(it => it.Save(sourceMock.Object));
        }
Example #3
0
        public void TesSave_serverSourceNull()
        {
            //arrange
            var expectedAuthenticationType = AuthenticationType.User;
            var expectedServerName         = "someServerName";
            var expectedPassword           = "******";
            var expectedUserName           = "******";
            var expectedName       = "someExpectedName";
            var expectedHeaderText = expectedName;
            var expectedHeader     = expectedName;
            var expectedPath       = "somePath";

            _requestServiceNameViewModelMock.Setup(it => it.ShowSaveDialog()).Returns(MessageBoxResult.OK);
            _requestServiceNameViewModelMock.SetupGet(it => it.ResourceName)
            .Returns(new ResourceName(expectedPath, expectedName));
            _targetRequestServiceViewModel.AuthenticationType = expectedAuthenticationType;
            _targetRequestServiceViewModel.Password           = expectedPassword;
            _targetRequestServiceViewModel.UserName           = expectedUserName;
            _targetRequestServiceViewModel.ServerName         = expectedServerName;
            _targetRequestServiceViewModel.ResourceName       = expectedName;

            //act
            _targetRequestServiceViewModel.Save();

            //assert
            _requestServiceNameViewModelMock.Verify(it => it.ShowSaveDialog());
            Assert.IsInstanceOfType(_targetRequestServiceViewModel.Item, typeof(SharePointServiceSourceDefinition));
            _updateManagerMock.Verify(it => it.Save(_targetRequestServiceViewModel.Item));
            Assert.AreEqual(expectedAuthenticationType, _targetRequestServiceViewModel.Item.AuthenticationType);
            Assert.AreEqual(expectedServerName, _targetRequestServiceViewModel.Item.Server);
            Assert.AreEqual(expectedPassword, _targetRequestServiceViewModel.Item.Password);
            Assert.AreEqual(expectedName, _targetRequestServiceViewModel.Item.Name);
            Assert.AreNotEqual(Guid.Empty, _targetRequestServiceViewModel.Item.Id);
            _updateManagerMock.Verify(it => it.Save(It.IsAny <ISharepointServerSource>()));
            Assert.AreEqual(expectedHeaderText, _targetRequestServiceViewModel.HeaderText);
            Assert.AreEqual(expectedHeader, _targetRequestServiceViewModel.Header);
        }