상속: BindableBase, IConnectionViewModel
예제 #1
0
 public void Construction01() {
     var cm = new ConnectionViewModel();
     cm.IsUserCreated.Should().BeTrue();
     cm.IsValid.Should().BeFalse();
     cm.IsTestConnectionSucceeded.Should().BeFalse();
     cm.Name.Should().BeNull();
 }
예제 #2
0
        public void UpdatePathAndNameExtraSpace() {
            var cm = new ConnectionViewModel(Substitute.For<IConnection>());

            // Name doesn't have extra spaces
            cm.Path = "server ";
            cm.Name.Should().Be("server");
            cm.Path.Should().Be("server ");

            // Path is completed to include default scheme and port
            cm.UpdatePath();
            cm.Name.Should().Be("server");
            cm.Path.Should().Be("https://server:5444");
        }
예제 #3
0
        public void UpdatePathAndName() {
            var cm = new ConnectionViewModel(Substitute.For<IConnection>());

            // Name is updated to match the host name
            cm.Path = "server";
            cm.Name.Should().Be("server");
            cm.Path.Should().Be("server");

            // Path is completed to include default scheme and port
            cm.UpdatePath();
            cm.Name.Should().Be("server");
            cm.Path.Should().Be("https://server:5444");
        }
예제 #4
0
        public void SaveTooltips() {
            var uri = new Uri("http://microsoft.com");
            var conn = Substitute.For<IConnection>();

            var cm = new ConnectionViewModel(conn);
            cm.SaveButtonTooltip.Should().Be(Resources.ConnectionManager_ShouldHaveName);

            conn.Name.Returns("name");
            cm = new ConnectionViewModel(conn);
            cm.SaveButtonTooltip.Should().Be(Resources.ConnectionManager_ShouldHavePath);

            conn.Path.Returns("c:\\path");
            cm = new ConnectionViewModel(conn);
            cm.SaveButtonTooltip.Should().Be(Resources.ConnectionManager_Save);
        }
예제 #5
0
        public void Construction02() {
            var uri = new Uri("http://microsoft.com");
            var conn = Substitute.For<IConnection>();
            conn.Uri.Returns(uri);
            conn.Name.Returns("name");
            conn.Path.Returns("path");
            conn.RCommandLineArguments.Returns("arg");
            conn.IsRemote.Returns(true);

            var cm = new ConnectionViewModel(conn);
            cm.IsUserCreated.Should().BeFalse();

            conn.IsUserCreated.Returns(true);
            cm = new ConnectionViewModel(conn);

            conn.IsRemote.Should().BeTrue();
            cm.IsUserCreated.Should().BeTrue();
            cm.IsEditing.Should().BeFalse();
            cm.IsTestConnectionSucceeded.Should().BeFalse();
            cm.Name.Should().Be(conn.Name);
            cm.Path.Should().Be(conn.Path);
            cm.RCommandLineArguments.Should().Be(conn.RCommandLineArguments);
        }
예제 #6
0
        public void ConnectionTooltip() {
            var conn = Substitute.For<IConnection>();
            conn.IsRemote.Returns(true);
            conn.Path.Returns("http://host");
            var cm = new ConnectionViewModel(conn);
            cm.ConnectionTooltip.Should().Be(
                Resources.ConnectionManager_InformationTooltipFormatRemote.FormatInvariant(cm.Path, Resources.ConnectionManager_None));

            conn = Substitute.For<IConnection>();
            conn.Path.Returns("C:\\");
            cm = new ConnectionViewModel(conn);
            cm.ConnectionTooltip.Should().Be(
                Resources.ConnectionManager_InformationTooltipFormatLocal.FormatInvariant(cm.Path, Resources.ConnectionManager_None));
        }
예제 #7
0
        [InlineData("https://server:5555", "serveR", "https://server:4444", "serveR")]        // case preserved
        public void UpdateName(string originalPath, string originalName, string changedPath, string expectedUpdatedName) {
            var conn = Substitute.For<IConnection>();
            conn.Name.Returns(originalName);
            conn.Path.Returns(originalPath);

            var cm = new ConnectionViewModel(conn);

            cm.Path = changedPath;
            cm.Name.Should().Be(expectedUpdatedName);
        }