Exemplo n.º 1
0
        public void TestToModelItemNullSourceNotNull()
        {
            //arrange
            var expectedAuthenticationType = AuthenticationType.User;
            var expectedServerName         = "someServerName";
            var expectedPassword           = "******";
            var expectedUserName           = "******";

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

            //act
            var result = _targetSource.ToModel();

            //assert
            Assert.AreSame(result, _targetSource.Item);
            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);
        }
Exemplo n.º 2
0
        public void TestToModelItemNotNull()
        {
            //arrange
            var serverSourceMock = new Mock <ISharepointServerSource>();

            _target.Item = serverSourceMock.Object;

            var expectedAuthenticationType = AuthenticationType.User;
            var expectedName     = "someName";
            var expectedPassword = "******";
            var expectedServer   = "someServerName";
            var expectedId       = Guid.NewGuid();
            var expectedUserName = "******";
            var expectedPath     = "somePath";

            serverSourceMock.SetupGet(it => it.Id).Returns(expectedId);

            _target.ResourceName       = expectedName;
            _target.ServerName         = expectedServer;
            _target.AuthenticationType = expectedAuthenticationType;
            _target.UserName           = expectedUserName;
            _target.Password           = expectedPassword;
            _target.Path = expectedPath;

            //act
            var value    = _target.ToModel();
            var hashcode = value.GetHashCode();

            //assert
            Assert.AreEqual(expectedAuthenticationType, value.AuthenticationType);
            Assert.AreEqual(expectedServer, value.Server);
            Assert.AreEqual(expectedPassword, value.Password);
            Assert.AreEqual(expectedName, value.Name);
            Assert.AreEqual(expectedUserName, value.UserName);
            Assert.AreEqual(expectedId, value.Id);
            Assert.AreEqual(expectedPath, value.Path);
            Assert.AreEqual(hashcode, value.GetHashCode());
        }