public void Extend(ITestController testController, object suite)
        {
            var fields = suite.GetType().GetFields(MemberBindings.Instance).ToList();
              if (fields.Count == 0)
            return;

              testController.AddAction<SetupExtension>("<Reset_Instance_Fields>", x => fields.ForEach(f => f.SetValue(suite, f.FieldType.GetDefaultValue())));
        }
Пример #2
0
        public void Extend(ITestController testController, object suite)
        {
            var fields = suite.GetType().GetFields(MemberBindings.Instance).ToList();

            if (fields.Count == 0)
            {
                return;
            }

            testController.AddAction <SetupExtension>("<Reset_Instance_Fields>", x => fields.ForEach(f => f.SetValue(suite, f.FieldType.GetDefaultValue())));
        }
        private void SetupFakes(ITestController testController, object suite)
        {
            var fieldsWithAttribute = suite.GetType().GetFieldsWithAttribute <ReturnedFromAttribute>().ToList();

            if (fieldsWithAttribute.Count == 0)
            {
                return;
            }

            testController.AddAction <SetupExtension>("<Setup_Fakes>", x => fieldsWithAttribute.ForEach(t => SetupFakeReturnValue(suite, t.Item2, t.Item1)));
        }
        private void CreateFakes(ITestController testController, object suite)
        {
            var fieldsWithAttribute = suite.GetType().GetFieldsWithAttribute <FakeBaseAttribute>().ToList();

            if (fieldsWithAttribute.Count == 0)
            {
                return;
            }

            testController.AddAction <SetupExtension>("<Create_Fakes>", x => fieldsWithAttribute.ForEach(t => CreateAndAssignFake(suite, t.Item2, t.Item1)));
        }
        public void Extend(ITestController testController, object suite)
        {
            var fieldsWithAttribute = suite.GetType().GetFieldsWithAttribute <DefaultAttribute>()
                                      .Where(x => x.Item1.FieldType.IsInstantiatable <object>()).ToList();

            if (fieldsWithAttribute.Count == 0)
            {
                return;
            }

            testController.AddAction <SetupExtension>("<Create_DefaultValues>", x => fieldsWithAttribute.ForEach(t => CreateDefaultValue(suite, t.Item1)));
        }
Пример #6
0
        public void Extend(ITestController testController, object suite)
        {
            var suiteType           = suite.GetType();
            var fieldsWithAttribute = suiteType.GetFieldsWithAttribute <AutoDataAttribute>()
                                      .OrderBy(x => x.Item1.Name).ToList();

            if (fieldsWithAttribute.Count == 0)
            {
                return;
            }

            var seed          = GetSeed(suiteType);
            var random        = new DefaultRandom(seed);
            var configuration = GetAutoDataConfiguration(suiteType);

            var generator = TestDataGeneratorFactory.Create(x => configuration(x).UseRandom(random));

            // TODO: add seed to data
            testController.AddAction <SetupExtension>(
                $"<Create_AutoData><{seed}>",
                x => fieldsWithAttribute.ForEach(t => CreateAndAssignAuto(suite, generator, t.Item2, t.Item1)));
        }