Ejemplo n.º 1
0
        public void TestResolveMultitonFromFactoryClearInstances()
        {
            _iocContainer.RegisterMultiton <ITest, Test, MultitonScope>();
            _iocContainer.RegisterFactory <ITestFactory>();

            MultitonScope scope1 = new MultitonScope();
            MultitonScope scope2 = new MultitonScope();

            ITestFactory testFactory = _iocContainer.Resolve <ITestFactory>();

            ITest resolvedTest1 = testFactory.Create(scope1);
            ITest resolvedTest2 = testFactory.Create(scope1);
            ITest resolvedTest3 = testFactory.Create(scope2);

            Assert.AreSame(resolvedTest1, resolvedTest2);
            Assert.AreNotSame(resolvedTest1, resolvedTest3);
            Assert.AreNotSame(resolvedTest2, resolvedTest3);

            testFactory.ClearMultitonInstance <ITest>();

            ITest resolvedTest4 = testFactory.Create(scope1);
            ITest resolvedTest5 = testFactory.Create(scope2);

            Assert.AreNotSame(resolvedTest1, resolvedTest4);
            Assert.AreNotSame(resolvedTest2, resolvedTest4);
            Assert.AreNotSame(resolvedTest3, resolvedTest5);
        }
Ejemplo n.º 2
0
 public TestRunner(ITestFactory testFactory, IJSRuntime jsRuntime, ILogger <TestRunner> logger, IServiceProvider serviceProvider)
 {
     this.testFactory     = testFactory;
     this.jsRuntime       = jsRuntime;
     this.logger          = logger;
     this.serviceProvider = serviceProvider;
     thisRef            = DotNetObjectReference.Create(this);
     testClassInstances = new Dictionary <Type, object>();
 }
Ejemplo n.º 3
0
        public void TestResolveFactory()
        {
            _iocContainer.Register <ITest, Test>();
            _iocContainer.RegisterFactory <ITestFactory>();

            ITestFactory testFactory = _iocContainer.Resolve <ITestFactory>();

            Assert.IsInstanceOf <ITestFactory>(testFactory);
        }
Ejemplo n.º 4
0
        public void TestResolveFromFactoryWithByte()
        {
            _iocContainer.Register <ITest, TestByte>();
            _iocContainer.RegisterFactory <ITestFactory>();

            ITestFactory testFactory = _iocContainer.Resolve <ITestFactory>();
            ITest        createdTest = testFactory.Create(1);

            Assert.IsInstanceOf <TestByte>(createdTest);
        }
Ejemplo n.º 5
0
        public void TestResolveFromFactoryWithDefaultParamCtor()
        {
            _iocContainer.Register <ITest, TestConstructor>();
            _iocContainer.Register <Test, Test>(); //this registration is abnormal and should only be used in unit tests
            _iocContainer.RegisterFactory <ITestFactory>();

            ITestFactory testFactory = _iocContainer.Resolve <ITestFactory>();
            ITest        createdTest = testFactory.Create();

            Assert.IsInstanceOf <TestConstructor>(createdTest);
        }
Ejemplo n.º 6
0
        private void StartTestSession()
        {
            ITestFactory testFactory = GetPlatformSpecificTestLibrary();

#if UNITY_IOS
            _testFactoryiOS = testFactory as TestFactoryiOS;
#endif

            // Set specific tests to run.
            // testFactory.AddTest("current/eventBuffering/Test_EventBuffering_sensitive_packets");
            // testFactory.AddTest("current/gdpr/Test_GdprForgetMe_after_install");

            Log("Starting test session...");
            testFactory.StartTestSession();
        }
Ejemplo n.º 7
0
        public TestUtility(IRepository <Test> testRepository,
                           IRepository <AnsweredQuestion> answeredQuestionRepository,
                           ITestFactory testFactory,
                           IHelperFactory helperFactory,
                           IDateTimeProvider dateTimeProvider,
                           IUnitOfWork unitOfWork)
        {
            Guard.WhenArgument(testRepository, "testRepository cannot be null").IsNull().Throw();
            Guard.WhenArgument(answeredQuestionRepository, "answeredQuestionRepository cannot be null").IsNull().Throw();
            Guard.WhenArgument(testFactory, "testFactory cannot be null").IsNull().Throw();
            Guard.WhenArgument(helperFactory, "helperFactory cannot be null").IsNull().Throw();
            Guard.WhenArgument(dateTimeProvider, "dateTimeProvider cannot be null").IsNull().Throw();
            Guard.WhenArgument(unitOfWork, "unitOfWork cannot be null").IsNull().Throw();

            this.testRepository             = testRepository;
            this.answeredQuestionRepository = answeredQuestionRepository;
            this.testFactory      = testFactory;
            this.helperFactory    = helperFactory;
            this.dateTimeProvider = dateTimeProvider;
            this.unitOfWork       = unitOfWork;
        }
Ejemplo n.º 8
0
		public ContextfulTest(ITestFactory factory)
		{
			_factory = factory;
		}
Ejemplo n.º 9
0
 public GetMethodsGenerator(ISdkCategorizer sdkCategorizer, ITestFactory <IResourceApi, ITest> testFactory)
 {
     _sdkCategorizer = sdkCategorizer;
     _testFactory    = testFactory;
 }
Ejemplo n.º 10
0
 public CommandExecutor(ITestFactory testFactory, string baseUrl, string gdprUrl)
 {
     _baseUrl     = baseUrl;
     _gdprUrl     = gdprUrl;
     _testFactory = testFactory;
 }
Ejemplo n.º 11
0
 public GetMethodsGenerator(Dictionary <string, Resource> resources, ITestFactory <Resource, ITest> testFactory)
 {
     _resources   = resources;
     _testFactory = testFactory;
 }
Ejemplo n.º 12
0
 public Order(ITestFactory testFactory)
 {
     this.testFactory = testFactory;
 }
Ejemplo n.º 13
0
 public TestController(ITestFactory testFactory, ILogger <TestController> logger)
 {
     _testFactory = testFactory ?? throw new ArgumentNullException(nameof(testFactory));
     _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Dictionary <int, string> enginesID = new Dictionary <int, string> // словарь, содержащий список всех имеющихся типов двигателей
            {
                { 1, "1. ДСВ" }
            };
            Dictionary <int, string> testsID = new Dictionary <int, string> // словарь, содержащий список всех имеющихся типов тестовых стендов
            {
                { 1, "1. Рассчёт времени перегрева двигателя" }
            };

            double       tAmbient;         // температура окружающей среды в градусах °C
            int          selectedEngineID; // номер выбранного двигателя
            int          selectedTestID;   // номер выбранного теста
            IEngine      engine    = null;
            ITestFactory testStand = null;

            Console.Write("Введите температуру окружающей среды в градусах °C: ");

            #region// проверка на корректность ввода температуры
            while (true)
            {
                try
                {
                    tAmbient = Convert.ToDouble(Console.ReadLine());
                    break;
                }
                catch (FormatException)
                {
                    Console.Write("Введено некорректное значение! Введите число: ");
                }
            }
            #endregion

            #region//выбор типа двигателя, проверка на корректность ввода и наличия двигателя в словаре
            Console.WriteLine("\nВыберите тип двигателя, для проведения тестирования:");

            foreach (var eng in enginesID)
            {
                Console.WriteLine(eng.Value);
            }

            Console.Write("Введите число: ");

            // проверка на корректность ввода и наличие двигателя в словаре
            while (true)
            {
                try
                {
                    selectedEngineID = Convert.ToInt32(Console.ReadLine());

                    foreach (int ind in enginesID.Keys)
                    {
                        if (selectedEngineID == ind)
                        {
                            switch (selectedEngineID)
                            {
                            case 1:
                                engine = new InternalCombustionEngine(tAmbient);
                                break;
                            }
                        }
                        else
                        {
                            throw new Exception("Такого двигателя не существует!");
                        }
                    }
                    break;
                }
                catch (FormatException)
                {
                    Console.Write("Введено некорректное значение! Введите число целое: ");
                }
                catch (Exception)
                {
                    Console.Write("Такого двигателя не существует! Попробуйте снова: ");
                }
            }
            #endregion

            #region//выбор типа тестового стенда, проверка на корректность ввода и наличия тестового стенда в словаре
            Console.WriteLine("\nВыберите тип теста:");

            foreach (var eng in testsID)
            {
                Console.WriteLine(eng.Value);
            }

            Console.Write("Введите число: ");

            // проверка на корректность ввода и наличие теста в словаре
            while (true)
            {
                try
                {
                    selectedTestID = Convert.ToInt32(Console.ReadLine());

                    foreach (int ind in testsID.Keys)
                    {
                        if (selectedTestID == ind)
                        {
                            switch (selectedTestID)
                            {
                            case 1:
                                testStand = new OverheatTimeTest(engine);
                                break;
                            }
                        }
                        else
                        {
                            throw new Exception("Такого теста не существует!");
                        }
                    }
                    break;
                }
                catch (FormatException)
                {
                    Console.Write("Введено некорректное значение! Введите число целое: ");
                }
                catch (Exception)
                {
                    Console.Write("Такого теста не существует! Попробуйте снова: ");
                }
            }
            #endregion

            testStand.StartSimulation();
            testStand.Controller();

            Console.ReadKey();
        }
Ejemplo n.º 15
0
 public DestructiveMethodsGenerator(IModelDependencySort modelDependencySort,
                                    ITestFactory <IResourceApi, ITest> testFactory)
 {
     _modelDependencySort = modelDependencySort;
     _testFactory         = testFactory;
 }
Ejemplo n.º 16
0
 public ContextfulTest(ITestFactory factory)
 {
     _factory = factory;
 }
Ejemplo n.º 17
0
 public Tester(ISeeder seeder, ITestFactory testFactory)
 {
     seeder.Seed();
     Tests = testFactory.Tests;
 }