public void TestCacheReload()
        {
            // tests that the identical object is retrieved from the cache (e.g., default not re-created)
            KmlLiveCam kmlLiveCam1  = liveCamRegistry.LoadByAlias(Alias1);
            KmlLiveCam kmlLiveCam2  = liveCamRegistry.LoadByAlias(Alias2);
            KmlLiveCam kmlLiveCam2b = liveCamRegistry.LoadByAlias(Alias2);
            KmlLiveCam kmlLiveCam1b = liveCamRegistry.LoadByAlias(Alias1);

            Assert.True(kmlLiveCam1 == kmlLiveCam1b);
            Assert.True(kmlLiveCam2 == kmlLiveCam2b);
        }
        public void TestSingleRegistrationAndRetrieval()
        {
            Assert.False(liveCamRegistry.TryGetById(Alias1, out _));
            KmlLiveCam kmlLiveCam1 = liveCamRegistry.LoadByAlias(Alias1);

            Assert.NotNull(kmlLiveCam1);
            KmlLiveCam kmlLiveCam1b;

            Assert.True(liveCamRegistry.TryGetById(Alias1, out kmlLiveCam1b));
            Assert.Equal(kmlLiveCam1, kmlLiveCam1b);
        }
        public void TestCamerTemplateScriptRendering()
        {
            var kmlLiveCam = new KmlLiveCam(
                new LiveCamEntity(
                    new LiveCamLensEntity("camera", "return $\"seq({seq})\";"),
                    new LiveCamLensEntity("link", "return $\"lensUrl({lensUrl})\";")
                    )
                );
            KmlCameraParameterValues camValues = new KmlCameraParameterValues {
                seq = 678
            };
            KmlCameraParameterValues linkValues = new KmlCameraParameterValues {
                listenerUrl = "hey!", alias = "a", lens = "l"
            };

            Assert.Equal("seq(678)", kmlLiveCam.GetLens("camera").Render(camValues));
            Assert.Equal("lensUrl(hey!//a/l)", kmlLiveCam.GetLens("link").Render(linkValues));
        }
        public void TestDoubleRegistrationAndRetrieval()
        {
            // TODO - improve this rather devolved test
            KmlLiveCam kmlLiveCam1 = liveCamRegistry.LoadByAlias(Alias1);

            Assert.NotNull(kmlLiveCam1);
            Assert.NotNull(kmlLiveCam1.LensNames);
            KmlLiveCam kmlLiveCam2;

            Assert.False(liveCamRegistry.TryGetById(Alias2, out kmlLiveCam2));
            Assert.Null(kmlLiveCam2);
            KmlLiveCam kmlLiveCam2b = liveCamRegistry.LoadByAlias(Alias2);
            KmlLiveCam kmlLiveCam1b, kmlLiveCam2c;

            Assert.True(liveCamRegistry.TryGetById(Alias1, out kmlLiveCam1b));
            Assert.True(liveCamRegistry.TryGetById(Alias2, out kmlLiveCam2c));
            Assert.Equal(kmlLiveCam1, kmlLiveCam1b);
            Assert.Equal(kmlLiveCam2b, kmlLiveCam2c);
        }
        public void TestCamerTemplateTextRendering()
        {
            var kmlLiveCam = new KmlLiveCam(
                new LiveCamEntity(
                    new LiveCamLensEntity("camera", "<cam({seq})"),
                    new LiveCamLensEntity("link", "<link({alias},{lensUrl})")
                    )
                );
            KmlCameraParameterValues camValues = new KmlCameraParameterValues
            {
                seq = 99
            };
            KmlCameraParameterValues linkValues = new KmlCameraParameterValues
            {
                liveCamUriPath = "lcp",
                alias          = "a76"
            };

            Assert.Equal("<cam(99)", kmlLiveCam.GetLens("camera").Render(camValues));
            Assert.Equal("<link(a76,/lcp/a76/)", kmlLiveCam.GetLens("link").Render(linkValues));
        }
        public void TestPersistenceUpdate()
        {
            // load default live cam for "Alias1" into "kmlLiveCam1"
            KmlLiveCam kmlLiveCam1 = liveCamRegistry.LoadByAlias(Alias1);

            // it should have an empty lens names structure
            Assert.NotNull(kmlLiveCam1.LensNames);
            Assert.False(kmlLiveCam1.LensNames.GetEnumerator().MoveNext());

            LiveCamEntity liveCamEntity;

            // ensure can load it from persistence registry
            Assert.True(persistenceRegistry.TryGetById(Alias1, out liveCamEntity));

            // and verify it has no templates
            Assert.Empty(liveCamEntity.Lens);

            // create a new "kmlLiveCam2" with some templates in it
            KmlLiveCam kmlLiveCam2 = NewStandardCameraLinkLiveCam();

            // and save that into the registry, replacing as "Alias1"
            liveCamRegistry.Save(Alias1, kmlLiveCam2);

            // ensure can load it from the persistence registry
            Assert.True(persistenceRegistry.TryGetById(Alias1, out liveCamEntity));

            // and that is and the persistence repository now have the new, updated values
            Assert.Equal(2, liveCamEntity.Lens.Length);

            string liveCamLensCameraTemplate = kmlLiveCam2.GetLens(CAMERA_LENS_NAME).Template;

            Assert.Equal(UPDATED_CAMERA_TEMPLATE_VALUE, liveCamLensCameraTemplate);
            Assert.Equal(liveCamLensCameraTemplate, liveCamEntity.Lens[0].Template);

            string liveCamLensLinkTemplate = kmlLiveCam2.GetLens(LINK_LENS_NAME).Template;

            Assert.Equal(UPDATED_LINK_TEMPLATE_VALUE, liveCamLensLinkTemplate);
            Assert.Equal(liveCamLensLinkTemplate, liveCamEntity.Lens[1].Template);
        }