Ejemplo n.º 1
0
        public void GivenIOpenSharepointSource(string p0)
        {
            var manageSharepointServerSource = ScenarioContext.Current.Get <SharepointServerSource>(Utils.ViewNameKey);
            var mockStudioUpdateManager      = new Mock <ISharePointSourceModel>();

            mockStudioUpdateManager.Setup(model => model.ServerName).Returns("localhost");
            var mockEventAggregator = new Mock <IEventAggregator>();
            var mockExecutor        = new Mock <IServer>();

            var username = @"dev2\IntegrationTester";
            var password = TestEnvironmentVariables.GetVar(username);
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Name               = "Test",
                Server             = $"http://{Depends.SharepointBackupServer}",
                AuthenticationType = AuthenticationType.Windows,
                UserName           = "******",
                Password           = password
            };

            mockStudioUpdateManager.Setup(model => model.FetchSource(It.IsAny <Guid>()))
            .Returns(sharePointServiceSourceDefinition);
            var manageSharepointServerSourceViewModel = new SharepointServerSourceViewModel(mockStudioUpdateManager.Object, mockEventAggregator.Object, sharePointServiceSourceDefinition, new SynchronousAsyncWorker(), mockExecutor.Object);

            manageSharepointServerSource.DataContext = manageSharepointServerSourceViewModel;
            ScenarioContext.Current.Remove("viewModel");
            ScenarioContext.Current.Add("viewModel", manageSharepointServerSourceViewModel);
        }
Ejemplo n.º 2
0
        public void SharePointServiceSourceDefinition_Equals_SharepointSource_Expected_True()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedServer             = "localhost";
            const string             expectedPassword           = "******";
            const string             expectedUserName           = "******";

            var mockSharepointSource = new Mock <ISharepointSource>();

            mockSharepointSource.Setup(sharepointSource => sharepointSource.Server).Returns(expectedServer);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.UserName).Returns(expectedUserName);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Password).Returns(expectedPassword);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.AuthenticationType).Returns(expectedAuthenticationType);

            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition(mockSharepointSource.Object);

            var mockSharepointServerSource = new Mock <ISharepointServerSource>();

            mockSharepointServerSource.Setup(sharepointServerSource => sharepointServerSource.Server).Returns(expectedServer);
            mockSharepointServerSource.Setup(sharepointServerSource => sharepointServerSource.UserName).Returns(expectedUserName);
            mockSharepointServerSource.Setup(sharepointServerSource => sharepointServerSource.Password).Returns(expectedPassword);
            mockSharepointServerSource.Setup(sharepointServerSource => sharepointServerSource.AuthenticationType).Returns(expectedAuthenticationType);

            var isEqual = sharePointServiceSourceDefinition.Equals(mockSharepointServerSource.Object);

            Assert.IsTrue(isEqual);
        }
Ejemplo n.º 3
0
        public void SharePointServiceSourceDefinition_Equals_Object_GetType_Expected_False()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedServer             = "localhost";
            const string             expectedPath = "";
            var          expectedResourceID       = Guid.NewGuid();
            const string expectedResourceName     = "testResourceName";
            const string expectedPassword         = "******";
            const string expectedUserName         = "******";

            var mockSharepointSource = new Mock <ISharepointSource>();

            mockSharepointSource.Setup(sharepointSource => sharepointSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Server).Returns(expectedServer);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.GetSavePath()).Returns(expectedPath);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceID).Returns(expectedResourceID);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceName).Returns(expectedResourceName);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Password).Returns(expectedPassword);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.UserName).Returns(expectedUserName);

            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition(mockSharepointSource.Object);

            var sharepointSourceObj = new object();

            var isEqual = sharePointServiceSourceDefinition.Equals(sharepointSourceObj);

            Assert.IsFalse(isEqual);
        }
Ejemplo n.º 4
0
        public void SharePointServiceSourceDefinition_GetHashCode_Not_Equal_To_Zero()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedServer             = "localhost";
            const string             expectedPath = "";
            var          expectedResourceID       = Guid.NewGuid();
            const string expectedResourceName     = "testResourceName";
            const string expectedPassword         = "******";
            const string expectedUserName         = "******";

            var mockSharepointSource = new Mock <ISharepointSource>();

            mockSharepointSource.Setup(sharepointSource => sharepointSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Server).Returns(expectedServer);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.GetSavePath()).Returns(expectedPath);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceID).Returns(expectedResourceID);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceName).Returns(expectedResourceName);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Password).Returns(expectedPassword);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.UserName).Returns(expectedUserName);

            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition(mockSharepointSource.Object);

            var hashCode = sharePointServiceSourceDefinition.GetHashCode();

            Assert.AreNotEqual(0, hashCode);
        }
Ejemplo n.º 5
0
        public void SharePointServiceSourceDefinition_Validate()
        {
            const AuthenticationType expectedAuthenticationType = AuthenticationType.Public;
            const string             expectedServer             = "localhost";
            const string             expectedPath = "";
            var          expectedResourceID       = Guid.NewGuid();
            const string expectedResourceName     = "testResourceName";
            const string expectedPassword         = "******";
            const string expectedUserName         = "******";

            var mockSharepointSource = new Mock <ISharepointSource>();

            mockSharepointSource.Setup(sharepointSource => sharepointSource.AuthenticationType).Returns(expectedAuthenticationType);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Server).Returns(expectedServer);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.GetSavePath()).Returns(expectedPath);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceID).Returns(expectedResourceID);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.ResourceName).Returns(expectedResourceName);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.Password).Returns(expectedPassword);
            mockSharepointSource.Setup(sharepointSource => sharepointSource.UserName).Returns(expectedUserName);

            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition(mockSharepointSource.Object)
            {
                IsSharepointOnline = false
            };

            Assert.IsFalse(sharePointServiceSourceDefinition.IsSharepointOnline);

            Assert.AreEqual(expectedAuthenticationType, sharePointServiceSourceDefinition.AuthenticationType);
            Assert.AreEqual(expectedServer, sharePointServiceSourceDefinition.Server);
            Assert.AreEqual(expectedPath, sharePointServiceSourceDefinition.Path);
            Assert.AreEqual(expectedResourceID, sharePointServiceSourceDefinition.Id);
            Assert.AreEqual(expectedResourceName, sharePointServiceSourceDefinition.Name);
            Assert.AreEqual(expectedPassword, sharePointServiceSourceDefinition.Password);
            Assert.AreEqual(expectedUserName, sharePointServiceSourceDefinition.UserName);
        }
Ejemplo n.º 6
0
        public ISharepointServerSource FetchSource(Guid resourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(resourceID);
            var db   = new SharepointSource(xaml.ToXElement());
            var def  = new SharePointServiceSourceDefinition(db);

            return(def);
        }
Ejemplo n.º 7
0
        public void SharePointServiceSourceDefinition_Equals_SharepointSource_Null_Expected_False()
        {
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition();

            const ISharepointServerSource sharepointServerSource = null;

            var isEqual = sharePointServiceSourceDefinition.Equals(sharepointServerSource);

            Assert.IsFalse(isEqual);
        }
Ejemplo n.º 8
0
        public void SharePointServiceSourceDefinition_GetHashCode_Expect_Zero()
        {
            var mockSharepointSource = new Mock <ISharepointSource>();

            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition(mockSharepointSource.Object);

            var hashCode = sharePointServiceSourceDefinition.GetHashCode();

            Assert.AreEqual(0, hashCode);
        }
Ejemplo n.º 9
0
        public void SharePointServiceSourceDefinition_Equals_SharePointServiceSourceDefinition_Null_Expected_False()
        {
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition();

            const SharePointServiceSourceDefinition nullSharePointServiceSourceDefinition = null;

            var isEqual = sharePointServiceSourceDefinition.Equals(nullSharePointServiceSourceDefinition);

            Assert.IsFalse(isEqual);
        }
        public void SavedSource_Itself_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Id     = Guid.NewGuid(),
                Server = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(sharePointServiceSourceDefinition.Equals(sharePointServiceSourceDefinition), "Equals operator can't compare to itself.");
        }
        public void SavedSource_Null_Object_Is_NotEqual()
        {
            //---------------Set up test pack-------------------
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Id     = Guid.NewGuid(),
                Server = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(sharePointServiceSourceDefinition.Equals(null), "Equals operator can't compare to null.");
        }
Ejemplo n.º 12
0
 void ToItem()
 {
     Item = new SharePointServiceSourceDefinition()
     {
         Path               = _sharePointServiceSource.Path,
         Password           = _sharePointServiceSource.Password,
         UserName           = _sharePointServiceSource.UserName,
         AuthenticationType = _sharePointServiceSource.AuthenticationType,
         Name               = _sharePointServiceSource.Name,
         IsSharepointOnline = _sharePointServiceSource.IsSharepointOnline,
         Server             = _sharePointServiceSource.Server,
         Id = _sharePointServiceSource.Id,
     };
 }
        public void SavedSource_DifferentType_Is_NotEqual()
        {
            //---------------Set up test pack-------------------
            var sharePointServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Id     = Guid.NewGuid(),
                Server = "A"
            };
            object differentObject = new SharepointSearchTo
            {
                InternalName = Guid.NewGuid().ToString(),
                FieldName    = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(sharePointServiceSourceDefinition.Equals(differentObject), "Equals operator can't compare to differently typed object.");
        }
        public void NotEqualsOperator_WithNotEqualObjects_AreNotEqual()
        {
            var firstEmailServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Name               = "Test",
                Server             = "companyweb",
                AuthenticationType = AuthenticationType.Windows,
                UserName           = "******",
                Password           = "******"
            };

            var secondEmailServiceSourceDefinition = new SharePointServiceSourceDefinition
            {
                Name               = "Different Test",
                Server             = "differentcompanyweb",
                AuthenticationType = AuthenticationType.Anonymous
            };

            Assert.IsTrue(firstEmailServiceSourceDefinition != secondEmailServiceSourceDefinition, "Not equals operator doesnt work.");
        }