Example #1
0
        private static void AddUpdateDeleteDynamicDataTest()
        {
            Console.WriteLine("Add_Update_Delete_DynamicData Test");
            //arrange
            ICacheProvider cacheProvider =
                new CacheProvider(new CacheItemPolicy
                {
                    AbsoluteExpiration = DateTimeOffset.MinValue,
                    SlidingExpiration = TimeSpan.Zero
                });
            IResourceManager resourceManager = new ResourceManager(cacheProvider);

            string expectedvalue = "5";
            string expectedNewValue = "6";

            var dynamicData = new DynamicTranslationsData
            {
                DescriptionValue = "5",
                DynamicKey = "5",
                Value = "5",
                LanguageId = 1
            };

            //Add dynamic data
            resourceManager.AddResource(dynamicData);
            Console.WriteLine("The dynamic data were added successfully");

            string actualValue = resourceManager.GetResource(TranslationTypeEnum.DynamicTranslation,
                dynamicData.DynamicKey, "uk");

            Console.WriteLine("ADDING... Actual value:{0} \t Expected value:{1}", actualValue, expectedvalue);
            Console.WriteLine("Press anykey to continue...");
            Console.ReadKey();

            //Update dynamic data
            dynamicData.Value = "6";
            resourceManager.UpdateResource(dynamicData);
            Console.WriteLine("The dynamic data were updateded successfully");

            string actualNewValue = resourceManager.GetResource(TranslationTypeEnum.DynamicTranslation,
                dynamicData.DynamicKey, "uk");

            Console.WriteLine("UPDATING... Actual value:{0} \t Expected value:{1}", actualNewValue, expectedNewValue);
            Console.WriteLine("Press anykey to continue...");
            Console.ReadKey();

            //Delete dynamic data
            resourceManager.DeleteDynamicResource(new List<string>(){"5"});
            Console.WriteLine("The dynamic data were deleted successfully");
            Console.WriteLine("Press anykey to finish current test.");
            Console.WriteLine("-----------------------------");
        }