示例#1
0
        public void ProtocolWhenNullableAndNull_WhenCheckedIfPass_ReturnsTrue()
        {
            //Arrange: a protocol with a constrain containing a max length and a string
            //above that length is created.
            Repository.Business.Protocols.Premise nullableConstraint =
                new Repository.Business.Protocols.Premise{
                nullable = true
            };
            Protocol nullableProtocol = Protocol.WithPremise(
                nullableConstraint,
                "Null string"
            );

            //Act: the protocol is checked to pass the test.
            bool passes = nullableProtocol.passes(null);

            //Assert: the protocol passes the test.
            Assert.IsTrue(passes);
        }
示例#2
0
        public void ProtocolWhenNotNullableAndNull_WhenCheckedIfPass_ReturnsFalse()
        {
            Repository.Business.Protocols.Premise nullableConstraint =
                new Repository.Business.Protocols.Premise{
                nullable = false
            };
            Protocol nullableProtocol = Protocol.WithPremise(
                nullableConstraint,
                "Null string"
            );

            //Act: the protocol is checked to pass the test.
            bool passes = nullableProtocol.passes(null);

            //Assert: the protocol passes the test.
            Assert.IsFalse(passes);
        }
示例#3
0
        public void ProtocolWhenBelowMinLength_WhenCheckedIfPass_ReturnsFalse()
        {
            //Arrange: a protocol with a constrain containing a min length and a string
            //below that length is created.
            Repository.Business.Protocols.Premise minLengthConstraint =
                new Repository.Business.Protocols.Premise{
                minLength = 2
            };
            Protocol minLengthProtocol = Protocol.WithPremise(
                minLengthConstraint,
                "One"
            );

            //Act: the protocol is checked to pass the test.
            bool passes = minLengthProtocol.passes("1");

            //Assert: the protocol fails the test.
            Assert.IsFalse(passes);
        }
示例#4
0
        public void ProtocolWhenBelowMaxLength_WhenCheckedIfPass_ReturnsTrue()
        {
            //Arrange: a protocol with a constrain containing a max length and a string
            //above that length is created.
            Repository.Business.Protocols.Premise maxLengthConstraint =
                new Repository.Business.Protocols.Premise{
                minLength = 2,
                maxLength = 5
            };
            Protocol maxLengthProtocol = Protocol.WithPremise(
                maxLengthConstraint,
                "Long String"
            );

            //Act: the protocol is checked to pass the test.
            bool passes = maxLengthProtocol.passes("1234");

            //Assert: the protocol passes the test.
            Assert.IsTrue(passes);
        }
示例#5
0
        public void ProtocolStack_DeleteRule_WhenCheckedIfPass_ReturnsTrue()
        {
            Repository.Business.Protocols.Premise standardConstraint =
                new Repository.Business.Protocols.Premise{
                minLength = 2,
                maxLength = -1,
                nullable = false
            };
            string target = "";
            ProtocolStack protocolStack = ProtocolStack.WithPremise(
                standardConstraint,
                "valid string"
            );

            //Act: Check if the delete rules pass the test
            bool passes = protocolStack.Delete.passes(target);

            //Assert: the test has passed
            Assert.IsTrue(passes);
        }
示例#6
0
        public void ProtocolStack_CreateRule_WhenBelowMinLength_ReturnsFalse()
        {
            Repository.Business.Protocols.Premise standardConstraint =
                new Repository.Business.Protocols.Premise{
                minLength = 2,
                maxLength = 10,
                nullable = false
            };
            string target = "1";
            ProtocolStack protocolStack = ProtocolStack.WithPremise(
                standardConstraint,
                "invalid string"
            );

            //Act: Check if the create rules pass the test
            bool passes = protocolStack.Create.passes(target);

            //Assert: the test has passed
            Assert.IsFalse(passes);
        }