Esempio n. 1
0
        public UnitTestBase()
        {
            var testContainer = new TestsContainer();

            _container = testContainer.GetContainerBuilder();
            _container.Resolve <IEnumerable <IMapConfiguration> >().ToList().ForEach(x => x.Map());
            _container.Resolve <IEventRegisterListeners>().RegisterListeners();
            _translationsService = _container.Resolve <ITranslationsService>();

            _emailSenderMock = testContainer.EmailSenderMoq;

            HttpContext.Current = HttpContext.Current = new HttpContext(
                new HttpRequest("", "http://tempuri.org", ""),
                new HttpResponse(new StringWriter())
                );

            HttpContext.Current.User = new GenericPrincipal(
                new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.Role, RoleIds.SuperAdmin.ToString()),
                new Claim(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString()),
            }),
                new string[0]
                );
        }
Esempio n. 2
0
        public static TestsContainer LoadTests()
        {
            TestsContainer Container = new TestsContainer();

            TestLoader.LoadTest(out Container);
            return(Container);
        }
Esempio n. 3
0
 static void SaveTests(string path, TestsContainer container)
 {
     File.WriteAllText(path,
                       JsonConvert.SerializeObject(container, new JsonSerializerSettings
     {
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     }));
 }
Esempio n. 4
0
 private void CreateContainer()
 {
     if (TestsContainer == null)
     {
         TestsContainer = new TestsContainer();
     }
     if (TestsContainer.Tests == null)
     {
         TestsContainer.Tests = new Test[1];
         CreateSampleTest();
     }
 }
Esempio n. 5
0
 public static void LoadTest(out TestsContainer test_man)
 {
     try
     {
         string    resources_path = TestCreator.Instance.AssetsPath + TestCreator.Instance.TestsFileName;
         TextAsset file           = Resources.Load <TextAsset>(resources_path);
         string    json_contents  = System.Text.Encoding.UTF7.GetString(file.bytes);
         test_man = JsonUtility.FromJson <TestsContainer>(json_contents);
     }
     catch (System.Exception)
     {
         test_man = null;
         Debug.LogError("Critical error loading the tests file.");
     }
 }
Esempio n. 6
0
        public void CreateSampleTest()
        {
            if (TestsContainer == null)
            {
                TestsContainer = new TestsContainer();
            }
            if (Tests == null || Tests.Length <= 0)
            {
                Tests = new Test[1] {
                    GetSampleTest()
                }
            }
            ;

            SaveTests();
        }