示例#1
0
    public void DeserializeNativePmWithBackButtonUiElementPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": ""HomeView"",
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            {
               ""id"": ""BackButton"",
               ""type"": ""NativeButton"",
               ""name"": ""Back button"",
               ""settings"": {
                  ""text"": ""Back"",
                  ""startFocus"": false,
                  ""style"": {
                     ""backgroundColor"": ""#ffffff"",
                     ""font"": {
                        ""fontSize"": 16,
                        ""fontWeight"": ""400"",
                        ""color"": ""#000000"",
                        ""fontFamily"": ""arial, helvetica, sans-serif""
                     }
                  }               
               }
            }
        ]
      }
    ]
}";
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsNotEmpty(elements);
        Assert.AreEqual(elements.Count, 1);
        Assert.AreEqual(elements["HomeView"].Count, 1);
        var el = elements["HomeView"][0] as CmpBackButtonModel;

        Assert.IsNotNull(el);
        Assert.AreEqual(el.id, "BackButton");
        Assert.AreEqual(el.type, "NativeButton");
        Assert.AreEqual(el.name, "Back button");
        Assert.AreEqual(el.Text, "Back");
        Assert.AreEqual(el.StartFocus !, false);
        Assert.AreEqual(el.BackgroundColor, "#ffffff");
        Assert.AreEqual(el.Font.Color, "#000000");
        Assert.AreEqual(el.Font.fontWeight, "400");
        Assert.AreEqual(el.Font.fontFamily, "arial, helvetica, sans-serif");
        Assert.AreEqual(el.Font.fontSize, 16);
    }
示例#2
0
    public void DeserializeNativePmNoChildrenPropertyFails()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"{
           ""id"": ""Root"",
           ""type"": ""NativeOtt"",
           ""name"": ""Native OTT""
        }";

        Assert.Catch <KeyNotFoundException>(delegate
        {
            Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);
        });
    }
示例#3
0
    public void DeserializeNativePmWithNullChildrenFails()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"{
           ""id"": ""Root"",
           ""type"": ""NativeOtt"",
           ""name"": ""Native OTT"",
           ""children"": null
        }";

        Assert.Catch <InvalidOperationException>(delegate
        {
            Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);
        });
    }
示例#4
0
    public void DeserializeNativePmWithNullUiElementPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": ""HomeView"",
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            null,
            {
               ""id"": ""Header"",
               ""type"": ""NativeText"",
               ""name"": ""Header"",
               ""settings"": {
                  ""text"": ""Privacy"",
                  ""style"": {
                     ""font"": {
                        ""fontSize"": 28,
                        ""fontWeight"": ""400"",
                        ""color"": ""#000000"",
                        ""fontFamily"": ""arial, helvetica, sans-serif""
                     }
                  }
               }
            }
        ]
      }
    ]
}";
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsNotEmpty(elements);
        Assert.AreEqual(elements.Count, 1);
        Assert.AreEqual(elements["HomeView"].Count, 1);
        Assert.IsNotNull(elements["HomeView"][0]);
    }
示例#5
0
    public void DeserializeNativePmWithNativeImageUiElementPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": ""HomeView"",
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            {
               ""id"": ""LogoImage"",
               ""type"": ""NativeImage"",
               ""name"": ""Logo"",
               ""settings"": {
                  ""src"": ""https://i.pinimg.com/originals/5a/ae/50/5aae503e4f037a5a4375944d8861fb6a.png"",
                  ""style"": {
                     ""width"": 170
                  }
               }
            }
        ]
      }
    ]
}";
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsNotEmpty(elements);
        Assert.AreEqual(elements.Count, 1);
        Assert.AreEqual(elements["HomeView"].Count, 1);
        var el = elements["HomeView"][0] as CmpNativeImageModel;

        Assert.IsNotNull(el);
        Assert.AreEqual(el.id, "LogoImage");
        Assert.AreEqual(el.type, "NativeImage");
        Assert.AreEqual(el.name, "Logo");
        Assert.AreEqual(el.LogoImageLink, "https://i.pinimg.com/originals/5a/ae/50/5aae503e4f037a5a4375944d8861fb6a.png");
    }
示例#6
0
    public void DeserializeNativePmWithNoViewIdPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": null,
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            {
               ""id"": ""Header"",
               ""type"": ""NativeText"",
               ""name"": ""Header"",
               ""settings"": {
                  ""text"": ""Privacy"",
                  ""style"": {
                     ""font"": {
                        ""fontSize"": 28,
                        ""fontWeight"": ""400"",
                        ""color"": ""#000000"",
                        ""fontFamily"": ""arial, helvetica, sans-serif""
                     }
                  }
               }
            }
        ]
      }
    ]
}";

        LogAssert.Expect(LogType.Error, ">>>DAFUQ >:C");
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsEmpty(elements);
        Assert.IsEmpty(popupBgColors);
    }
示例#7
0
    public void DeserializeNativePmWithLongButtonUiElementPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": ""HomeView"",
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            {
               ""id"": ""VendorButton"",
               ""type"": ""LongButton"",
               ""name"": ""Vendors Buttons"",
               ""settings"": {
                  ""onText"": ""On"",
                  ""offText"": ""Off"",
                  ""customText"": ""Custom"",
                  ""style"": {
                     ""font"": {
                        ""fontSize"": 14,
                        ""fontWeight"": ""400"",
                        ""fontFamily"": ""arial, helvetica, sans-serif"",
                        ""color"": ""#060606""
                     },
                     ""onFocusBackgroundColor"": ""#ffffff"",
                     ""onUnfocusBackgroundColor"": ""#f1f2f6""
                  }
               }
            }
        ]
      }
    ]
}";
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsNotEmpty(elements);
        Assert.AreEqual(elements.Count, 1);
        Assert.AreEqual(elements["HomeView"].Count, 1);
        var el = elements["HomeView"][0] as CmpLongButtonModel;

        Assert.IsNotNull(el);
        Assert.AreEqual(el.id, "VendorButton");
        Assert.AreEqual(el.type, "LongButton");
        Assert.AreEqual(el.name, "Vendors Buttons");
        Assert.AreEqual(el.OnText, "On");
        Assert.AreEqual(el.OffText, "Off");
        Assert.AreEqual(el.CustomText, "Custom");
        Assert.AreEqual(el.OnFocusColorCode, "#ffffff");
        Assert.AreEqual(el.OnUnfocusColorCode, "#f1f2f6");
        Assert.AreEqual(el.Font.Color, "#060606");
        Assert.AreEqual(el.Font.fontWeight, "400");
        Assert.AreEqual(el.Font.fontFamily, "arial, helvetica, sans-serif");
        Assert.AreEqual(el.Font.fontSize, 14);
    }
示例#8
0
    public void DeserializeNativePmWithSliderUiElementPasses()
    {
        Dictionary <string, string> popupBgColors = null;
        string json = @"
{
   ""id"": ""Root"",
   ""type"": ""NativeOtt"",
   ""name"": ""Native OTT"",
   ""children"": [
      {
         ""id"": ""HomeView"",
         ""type"": ""NativeView"",
         ""name"": ""Home View"",
         ""settings"": {
            ""style"": {
               ""backgroundColor"": ""#e5e8ef""
            }
         },
         ""children"": [
            {
               ""id"": ""CategoriesSlider"",
               ""type"": ""Slider"",
               ""name"": ""Categories Slider"",
               ""settings"": {
                  ""leftText"": ""CONSENT"",
                  ""rightText"": ""LEGITIMATE INTEREST"",
                  ""style"": {
                     ""backgroundColor"": ""#d8d9dd"",
                     ""activeBackgroundColor"": ""#777a7e"",
                     ""font"": {
                        ""fontSize"": 14,
                        ""fontWeight"": ""400"",
                        ""color"": ""#000000"",
                        ""fontFamily"": ""arial, helvetica, sans-serif""
                     },
                     ""activeFont"": {
                        ""fontSize"": 14,
                        ""fontWeight"": ""400"",
                        ""color"": ""#ffffff"",
                        ""fontFamily"": ""arial, helvetica, sans-serif""
                     }
                  }
               }
            }
        ]
      }
    ]
}";
        Dictionary <string, List <CmpUiElementModel> > elements = NativeUiJsonDeserializer.DeserializeNativePm(json, ref popupBgColors);

        Assert.IsNotEmpty(elements);
        Assert.AreEqual(elements.Count, 1);
        Assert.AreEqual(elements["HomeView"].Count, 1);
        var el = elements["HomeView"][0] as CmpSliderModel;

        Assert.IsNotNull(el);
        Assert.AreEqual(el.id, "CategoriesSlider");
        Assert.AreEqual(el.type, "Slider");
        Assert.AreEqual(el.name, "Categories Slider");
        Assert.AreEqual(el.LeftText, "CONSENT");
        Assert.AreEqual(el.RightText, "LEGITIMATE INTEREST");
        Assert.AreEqual(el.BackgroundColor, "#d8d9dd");
        Assert.AreEqual(el.ActiveBackgroundColor, "#777a7e");
        Assert.AreEqual(el.DefaultFont.Color, "#000000");
        Assert.AreEqual(el.DefaultFont.fontWeight, "400");
        Assert.AreEqual(el.DefaultFont.fontFamily, "arial, helvetica, sans-serif");
        Assert.AreEqual(el.DefaultFont.fontSize, 14);
        Assert.AreEqual(el.ActiveFont.Color, "#ffffff");
        Assert.AreEqual(el.ActiveFont.fontWeight, "400");
        Assert.AreEqual(el.ActiveFont.fontFamily, "arial, helvetica, sans-serif");
        Assert.AreEqual(el.ActiveFont.fontSize, 14);
    }