Example #1
0
        public void LockData_FromBody_Parsing()
        {
            // Verify simple vanilla parsing
            LockData lockDataBefore = new LockData(1, true, true, "git status --serialize=D:\\Sources\\tqoscy2l.ud0_status.tmp --ignored=matching --untracked-files=complete");
            LockData lockDataAfter  = LockData.FromBody(lockDataBefore.ToMessage());

            lockDataAfter.PID.ShouldEqual(1);
            lockDataAfter.IsElevated.ShouldEqual(true);
            lockDataAfter.CheckAvailabilityOnly.ShouldEqual(true);
            lockDataAfter.ParsedCommand.ShouldEqual("git status --serialize=D:\\Sources\\tqoscy2l.ud0_status.tmp --ignored=matching --untracked-files=complete");

            // Verify strings with "|" will work
            LockData lockDataWithPipeBefore = new LockData(1, true, true, "git commit -m 'message with a | and another |'");
            LockData lockDataWithPipeAfter  = LockData.FromBody(lockDataWithPipeBefore.ToMessage());

            lockDataWithPipeAfter.PID.ShouldEqual(1);
            lockDataWithPipeAfter.IsElevated.ShouldEqual(true);
            lockDataWithPipeAfter.CheckAvailabilityOnly.ShouldEqual(true);
            lockDataWithPipeAfter.ParsedCommand.ShouldEqual("git commit -m 'message with a | and another |'");

            // Verify exception cases and messages
            this.ValidateError("1|true|true", "Invalid lock message. Expected at least 5 parts, got: 3 from message: '1|true|true'");
            this.ValidateError("blah|true|true|10|git status", "Invalid lock message. Expected PID, got: blah from message: 'blah|true|true|10|git status'");
            this.ValidateError("1|true|1|10|git status", "Invalid lock message. Expected bool for checkAvailabilityOnly, got: 1 from message: '1|true|1|10|git status'");
            this.ValidateError("1|1|true|10|git status", "Invalid lock message. Expected bool for isElevated, got: 1 from message: '1|1|true|10|git status'");
            this.ValidateError("1|true|true|true|git status", "Invalid lock message. Expected command length, got: true from message: '1|true|true|true|git status'");
            this.ValidateError("1|true|true|5|git status", "Invalid lock message. The parsedCommand is an unexpected length, got: 5 from message: '1|true|true|5|git status'");
        }
        public void LockData_FromBody_WithDelimiters()
        {
            // Verify strings with "|" will work
            LockData lockDataWithPipeBefore = new LockData(1, true, true, "git commit -m 'message with a | and another |'", "123|321");
            LockData lockDataWithPipeAfter  = LockData.FromBody(lockDataWithPipeBefore.ToMessage());

            lockDataWithPipeAfter.PID.ShouldEqual(1);
            lockDataWithPipeAfter.IsElevated.ShouldEqual(true);
            lockDataWithPipeAfter.CheckAvailabilityOnly.ShouldEqual(true);
            lockDataWithPipeAfter.ParsedCommand.ShouldEqual("git commit -m 'message with a | and another |'");
            lockDataWithPipeAfter.GitCommandSessionId.ShouldEqual("123|321");
        }
        public void LockData_FromBody_Simple()
        {
            // Verify simple vanilla parsing
            LockData lockDataBefore = new LockData(1, true, true, "git status --serialize=D:\\Sources\\tqoscy2l.ud0_status.tmp --ignored=matching --untracked-files=complete", "123");
            LockData lockDataAfter  = LockData.FromBody(lockDataBefore.ToMessage());

            lockDataAfter.PID.ShouldEqual(1);
            lockDataAfter.IsElevated.ShouldEqual(true);
            lockDataAfter.CheckAvailabilityOnly.ShouldEqual(true);
            lockDataAfter.ParsedCommand.ShouldEqual("git status --serialize=D:\\Sources\\tqoscy2l.ud0_status.tmp --ignored=matching --untracked-files=complete");
            lockDataAfter.GitCommandSessionId.ShouldEqual("123");
        }
                public Response(Message message)
                {
                    this.Result = message.Header;

                    if (this.Result == DenyGSDResult)
                    {
                        this.DenyGSDMessage = message.Body;
                    }
                    else
                    {
                        this.ResponseData = LockData.FromBody(message.Body);
                    }
                }
 public LockRequest(string messageBody)
 {
     this.RequestData = LockData.FromBody(messageBody);
 }
Example #6
0
 public Response(Message message)
 {
     this.Result       = message.Header;
     this.ResponseData = LockData.FromBody(message.Body);
 }
        public void LockData_FromBody_Exception(string body, string exceptionMessage)
        {
            InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => LockData.FromBody(body));

            exception.Message.ShouldEqual(exceptionMessage);
        }
Example #8
0
 private void ValidateError(string body, string exceptionMessage)
 {
     Assert.Throws <InvalidOperationException>(() => LockData.FromBody(body)).Message.Equals(exceptionMessage);
 }