Beispiel #1
0
        public void SubmitOptionsNoneTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.None, 5, null, null, null);
                        SubmitResults    sr            = change.Submit(submitOptions);

                        FileSpec             fs       = FileSpec.DepotSpec("//depot/MyCode/NewFile.txt");
                        Options              ops      = new Options();
                        IList <FileMetaData> actual   = rep.GetFileMetaData(ops, fs);
                        FileAction           expected = FileAction.None;
                        Assert.AreEqual(expected, actual[0].Action);

                        Assert.IsNotNull(sr);
                        Assert.AreEqual(1, sr.Files.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void SubmitShelvedFromChangelist()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 13, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);
                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        // shelve the files in changelist 5
                        con.Client.ShelveFiles(new ShelveFilesCmdOptions(ShelveFilesCmdFlags.None,
                                                                         null, change.Id));

                        // revert the checked out file that was shelved
                        FileSpec file = new FileSpec(new DepotPath("//..."), null, null, null);
                        con.Client.RevertFiles(new RevertCmdOptions(RevertFilesCmdFlags.None, change.Id),
                                               file);

                        // submit the shelved file
                        SubmitCmdOptions submitOptions = new
                                                         SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.SubmitShelved,
                                                                          5, null, null, null);
                        change.Submit(submitOptions);

                        P4CommandResult last = rep.Connection.LastResults;
                        Assert.IsTrue(last.Success);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Beispiel #3
0
        public void RshConnectionTest()
        {
            bool unicode = false;

            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            var        p4d    = Utilities.DeployP4TestServer(TestDir, unicode, TestContext.TestName);
            Server     server = new Server(new ServerAddress("localhost:6666"));
            Repository rep    = new Repository(server);

            using (Connection con = rep.Connection)
            {
                con.UserName    = user;
                con.Client      = new Client();
                con.Client.Name = ws_client;
                bool connected = con.Connect(null);
                Assert.IsTrue(connected);
                Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                uint     cmdID = 7;
                string[] args  = new string[] { "stop" };
                Assert.IsTrue(con.getP4Server().RunCommand("admin", cmdID, false, args, args.Length));
                logger.Debug("Stopped launched server");
            }

            string uri = Utilities.TestRshServerPort(TestDir, unicode);

            server = new Server(new ServerAddress(uri));
            rep    = new Repository(server);
            logger.Debug("Created new server");
            try
            {
                using (Connection con = rep.Connection)
                {
                    con.UserName    = user;
                    con.Client      = new Client();
                    con.Client.Name = ws_client;

                    logger.Debug("About to connect");
                    Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);
                    Assert.IsTrue(con.Connect(null));
                    Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                    logger.Debug("Connected");
                    Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                    FileSpec fs = new FileSpec(new DepotPath("//depot/MyCode/ReadMe.txt"), null);
                    rep.Connection.Client.EditFiles(null, fs);
                    logger.Debug("File edited");
                }
            } finally
            {
                Utilities.RemoveTestServer(p4d, TestDir);
            }
        }
Beispiel #4
0
        public void SubmitTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;
                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);

                        Assert.AreEqual(con.Server.State, ServerState.Unknown);

                        Assert.IsTrue(con.Connect(null));

                        Assert.AreEqual(con.Server.State, ServerState.Online);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Assert.AreEqual("admin", con.Client.OwnerName);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        SubmitResults sr = change.Submit(null);

                        Assert.IsNotNull(sr);
                        Assert.AreEqual(1, sr.Files.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
Beispiel #5
0
        public void SubmitOptionsShelvedTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 1; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);
                        Assert.AreEqual(con.Server.State, ServerState.Unknown);
                        Assert.IsTrue(con.Connect(null));
                        Assert.AreEqual(con.Server.State, ServerState.Online);
                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                        Assert.AreEqual("admin", con.Client.OwnerName);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        Changelist change = new Changelist(5, true);
                        change.initialize(con);

                        FileSpec fs = FileSpec.DepotSpec("//depot/MyCode/NewFile.txt");
                        ShelveFilesCmdOptions shelvedOptions = new ShelveFilesCmdOptions(ShelveFilesCmdFlags.None, null, 5);
                        rep.Connection.Client.ShelveFiles(shelvedOptions, fs);
                        rep.Connection.Client.RevertFiles(null, fs);

                        SubmitResults sr = null;

                        try
                        {
                            SubmitCmdOptions submitOptions = new SubmitCmdOptions(Perforce.P4.SubmitFilesCmdFlags.SubmitShelved, 5, null, null, null);
                            sr = change.Submit(submitOptions);
                        }
                        catch (P4Exception e)
                        {
                            String msg = String.Format("Command '{0}' throws exception '{1}' \r\n StackTrace: {2}",
                                                       e.CmdLine,
                                                       e.Message,
                                                       e.StackTrace);
                            Assert.IsTrue(false, msg);
                        }

                        Assert.IsNotNull(sr);
                        Assert.AreEqual(1, sr.Files.Count);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
        public void GetChangelistWithUTCConversionTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";


            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 6, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);
                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);
                        Utilities.SetClientRoot(rep, TestDir, unicode, ws_client);

                        P4Command cmd  = new P4Command(rep, "change", true, "5");
                        Options   opts = new Options();
                        opts["-o"] = null;
                        Changelist fromChangeCommand = new Changelist();

                        P4CommandResult results = cmd.Run(opts);
                        if (results.Success)
                        {
                            fromChangeCommand.initialize(rep.Connection);
                            fromChangeCommand.FromChangeCmdTaggedOutput((results.TaggedOutput[0]),
                                                                        server.Metadata.DateTimeOffset, FormBase.DSTMismatch(server.Metadata));
                        }

                        SubmitResults sr = fromChangeCommand.Submit(null);

                        int submitted = 17;
                        if (unicode)
                        {
                            submitted = 13;
                        }

                        cmd               = new P4Command(rep, "change", true, submitted.ToString());
                        opts              = new Options();
                        opts["-o"]        = null;
                        fromChangeCommand = new Changelist();

                        results = cmd.Run(opts);
                        if (results.Success)
                        {
                            fromChangeCommand.initialize(rep.Connection);
                            fromChangeCommand.FromChangeCmdTaggedOutput((results.TaggedOutput[0]),
                                                                        server.Metadata.DateTimeOffset, FormBase.DSTMismatch(server.Metadata));
                        }

                        Changelist fromDescribeCommand = rep.GetChangelist(submitted, null);

                        Assert.AreEqual(fromDescribeCommand.ModifiedDate, fromChangeCommand.ModifiedDate);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }