Beispiel #1
0
        public void ObjectUrl_Mobile()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            // Create our methods for passing data around.
            string getPropertyText(Common.ObjVerEx o, int id)
            {
                Assert.Fail("Unexpected property retrieval");
                throw new InvalidOperationException();
            }

            string getObjectUrl(Common.ObjVerEx o, UrlTargetPlatform platform)
            {
                Assert.AreEqual(UrlTargetPlatform.Mobile, platform);
                return("https://weburl");
            }

            Common.ObjVerEx getDirectReference(Common.ObjVerEx o, int id)
            {
                Assert.Fail("Unexpected property retrieval");
                throw new InvalidOperationException();
            }

            Assert.AreEqual
            (
                "url is: https://weburl",
                objVerEx.ExpandSimpleConcatenation("url is: %OBJECTURL_MOBILE%", getPropertyText, getDirectReference, getObjectUrl)
            );
        }
Beispiel #2
0
        public void InvalidPropertyDefinitionThrows()
        {
            // Create our mock objects.
            var vaultMock = this.GetVaultMock();
            var root      = new Common.ObjVerEx
                            (
                vaultMock.Object,
                this.GetObjectVersionAndPropertiesMock(vaultMock, 0, 1).Object
                            );

            // Create our methods for passing data around.
            string getPropertyText(Common.ObjVerEx o, int id)
            {
                Assert.Fail("Unexpected property retrieval");
                throw new InvalidOperationException();
            }

            string getObjectUrl(Common.ObjVerEx o, UrlTargetPlatform platform)
            {
                Assert.Fail("Unexpected url access");
                throw new InvalidOperationException();
            }

            Common.ObjVerEx getDirectReference(Common.ObjVerEx o, int id)
            {
                Assert.Fail("Unexpected property retrieval");
                throw new InvalidOperationException();
            }

            // Output is expected.
            // Note: property definition with alias "first" is not found in the vault, so an exception is expected.
            var input = "resolves to: %PROPERTY_{first}.PROPERTY_456.PROPERTY_{last}%";

            root.ExpandSimpleConcatenation(input, getPropertyText, getDirectReference, getObjectUrl);
        }
Beispiel #3
0
        public void SingleExternalID()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("hello 123ABCDEF123 world", objVerEx.ExpandSimpleConcatenation("hello %EXTERNALID% world"));
        }
Beispiel #4
0
        public void MultipleInternalID()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("hello 123 world 123", objVerEx.ExpandSimpleConcatenation("hello %INTERNALID% world %INTERNALID%"));
        }
Beispiel #5
0
        public void DisplayID_WithExternalNoOriginal()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("hello 123ABCDEF123 world", objVerEx.ExpandSimpleConcatenation("hello %DISPLAYID% world"));
        }
Beispiel #6
0
        public void ObjectVersionID()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock, version: 23);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("hello 23 world", objVerEx.ExpandSimpleConcatenation("hello %OBJECTVERSIONID% world"));
        }
Beispiel #7
0
        public void ObjectGUID()
        {
            var guid      = Guid.NewGuid();
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock, objectGuid: guid);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual($"hello {guid:B} world", objVerEx.ExpandSimpleConcatenation("hello %OBJECTGUID% world"));
        }
Beispiel #8
0
        public void DisplayID_NoExternalWithOriginal()
        {
            var originalId = new ObjID();

            originalId.SetIDs(101, 1234);
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock, externalId: null, originalId: originalId);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("hello 1234 world", objVerEx.ExpandSimpleConcatenation("hello %DISPLAYID% world"));
        }
Beispiel #9
0
        public void VaultGUID()
        {
            var guid      = Guid.NewGuid().ToString("B");
            var vaultMock = this.GetVaultMock();

            vaultMock.Setup(o => o.GetGUID()).Returns(guid);
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock(vaultMock);
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual($"hello {guid} world", objVerEx.ExpandSimpleConcatenation("hello %VAULTGUID% world"));
        }
Beispiel #10
0
        public void PropertyIDWithNumber()
        {
            var vaultMock = this.GetVaultMock();
            var objectVersionAndPropertiesMock = this.GetObjectVersionAndPropertiesMock
                                                 (
                vaultMock,
                propertyValues: new Tuple <int, MFDataType, object>(0, MFDataType.MFDatatypeText, "hello world")
                                                 );
            var objVerEx = new Common.ObjVerEx(vaultMock.Object, objectVersionAndPropertiesMock.Object);

            Assert.AreEqual("document is called: hello world", objVerEx.ExpandSimpleConcatenation("document is called: %PROPERTY_0%"));
        }
Beispiel #11
0
        public void IndirectPropertyReferencePlaceholderNullReference()
        {
            // Create our mock objects.
            var vaultMock = this.GetVaultMock
                            (
                new Tuple <string, int>("first", 123),
                new Tuple <string, int>("last", 789)
                            );
            var root = new Common.ObjVerEx
                       (
                vaultMock.Object,
                this.GetObjectVersionAndPropertiesMock(vaultMock, 0, 1).Object
                       );

            // Create our methods for passing data around.
            string getPropertyText(Common.ObjVerEx o, int id)
            {
                Assert.Fail("Unexpected property retrieval");
                throw new InvalidOperationException();
            }

            string getObjectUrl(Common.ObjVerEx o, UrlTargetPlatform platform)
            {
                Assert.Fail("Unexpected url access");
                throw new InvalidOperationException();
            }

            Common.ObjVerEx getDirectReference(Common.ObjVerEx o, int id)
            {
                switch (id)
                {
                case 123:
                    return(null);

                default:
                    Assert.Fail("Unexpected property retrieval");
                    throw new InvalidOperationException();
                }
            }

            // Output is expected.
            // Note: property "first" returns null, as if the lookup were empty.
            // So the system should stop at this point and return an empty string.
            // BUT the other tokens (e.g. EXTERNALID) should still be resolved.
            var input = "resolves to: %PROPERTY_{first}.PROPERTY_456.PROPERTY_{last}% (%EXTERNALID%)";

            Assert.AreEqual("resolves to:  (123ABCDEF123)", root.ExpandSimpleConcatenation(input, getPropertyText, getDirectReference, getObjectUrl));
        }
Beispiel #12
0
        public void IndirectPropertyReferencePlaceholderMixture()
        {
            // Create our mock objects.
            var vaultMock = this.GetVaultMock
                            (
                new Tuple <string, int>("first", 123),
                new Tuple <string, int>("last", 789)
                            );
            var objectTwo = new Common.ObjVerEx
                            (
                vaultMock.Object,
                this.GetObjectVersionAndPropertiesMock(vaultMock, 0, 456).Object
                            );
            var objectOne = new Common.ObjVerEx
                            (
                vaultMock.Object,
                this.GetObjectVersionAndPropertiesMock(vaultMock, 0, 123).Object
                            );
            var root = new Common.ObjVerEx
                       (
                vaultMock.Object,
                this.GetObjectVersionAndPropertiesMock(vaultMock, 0, 1).Object
                       );

            // Create our methods for passing data around.
            string getPropertyText(Common.ObjVerEx o, int id)
            {
                switch (id)
                {
                case 789:
                    return("hello world");

                default:
                    Assert.Fail("Unexpected property retrieval");
                    throw new InvalidOperationException();
                }
            }

            Common.ObjVerEx getDirectReference(Common.ObjVerEx o, int id)
            {
                switch (id)
                {
                case 123:
                    return(objectOne);

                case 456:
                    return(objectTwo);

                default:
                    Assert.Fail("Unexpected property retrieval");
                    throw new InvalidOperationException();
                }
            }

            string getObjectUrl(Common.ObjVerEx o, UrlTargetPlatform platform)
            {
                Assert.Fail("Unexpected url access");
                throw new InvalidOperationException();
            }

            // Output is expected.
            var input = "resolves to: %PROPERTY_{first}.PROPERTY_456.PROPERTY_{last}%";

            Assert.AreEqual("resolves to: hello world", root.ExpandSimpleConcatenation(input, getPropertyText, getDirectReference, getObjectUrl));
        }