Exemplo n.º 1
0
        public void Should_parse_expressions_that_select_members_with_all_children_included()
        {
            var result = TestSubject.ParseFields("someProperty1,someReference(*)");

            Assert.That(result, Has.Count.EqualTo(2));

            Assert.That(
                result[0]
                .MemberName,
                Is.EqualTo("someProperty1"));

            Assert.That(
                result[0]
                .Children,
                Has.Count.EqualTo(0));

            Assert.That(
                result[1]
                .MemberName,
                Is.EqualTo("someReference"));

            Assert.That(
                result[1]
                .Children,
                Is.EqualTo(
                    new[]
            {
                "*"
            }));
        }
Exemplo n.º 2
0
        public void Should_parse_expressions_that_select_top_level_properties_even_with_trailing_spaces_in_the_expression()
        {
            var result = TestSubject.ParseFields("someProperty1,someProperty2  ");

            Assert.That(result, Has.Count.EqualTo(2));

            Assert.That(
                result[0]
                .MemberName,
                Is.EqualTo("someProperty1"));

            Assert.That(
                result[0]
                .Children,
                Has.Count.EqualTo(0));

            Assert.That(
                result[1]
                .MemberName,
                Is.EqualTo("someProperty2"));

            Assert.That(
                result[0]
                .Children,
                Has.Count.EqualTo(0));
        }
Exemplo n.º 3
0
        public async Task <TestSubject> PostTestSubject(TestSubject testSubject)
        {
            db.testSubject.Add(testSubject);
            await db.SaveChangesAsync();

            return(testSubject);
        }
Exemplo n.º 4
0
        public void Should_parse_expressions_that_select_members_with_specific_children_included_without_being_sensitive_to_leading_spaces()
        {
            var result = TestSubject.ParseFields("someProperty1,   someReference(  someRefProp1, someRefProp2)");

            Assert.That(result, Has.Count.EqualTo(2));

            Assert.That(
                result[0]
                .MemberName,
                Is.EqualTo("someProperty1"));

            Assert.That(
                result[0]
                .Children,
                Has.Count.EqualTo(0));

            Assert.That(
                result[1]
                .MemberName,
                Is.EqualTo("someReference"));

            Assert.That(
                result[1]
                .Children.Select(x => x.MemberName),
                Is.EqualTo(
                    new[]
            {
                "someRefProp1", "someRefProp2"
            }));
        }
Exemplo n.º 5
0
        public void Should_Update_Set_and_Get_Property()
        {
            var m = new TestSubject();

            m["Free"] = "Willy";
            Assert.That(m["Free"], Is.EqualTo("Willy"));
        }
Exemplo n.º 6
0
        public void LastNameTest()
        {
            TestSubject target   = new TestSubject();
            string      expected = null;

            Assert.AreEqual(expected, target.LastName);
        }
    public ICollection <ExperimentData> Resolve(TestSubject source, TestSubjectData destination, ICollection <ExperimentData> destMember, ResolutionContext context)
    {
        var destExperiments = new List <ExperimentData>();

        if (source.Experiments == null)
        {
            return(destExperiments);
        }

        foreach (var experiment in source.Experiments)
        {
            var experimentToAdd = new ExperimentData()
            {
                Id          = experiment.Id,
                Time        = experiment.Time,
                Comment     = experiment.Comment,
                TestSubject = new BasicTestSubject(experiment.TestSubject.Name,
                                                   experiment.TestSubject.Surname,
                                                   experiment.TestSubject.Id),
                GroupId = experiment.GroupId,
                Task    = new BasicData(experiment.Task.Name, experiment.TaskId)
            };

            destExperiments.Add(experimentToAdd);
        }
        return(destExperiments);
    }
Exemplo n.º 8
0
        public void Should_Find_Own_Getter_Only_Property()
        {
            var m = new TestSubject("abc");
            var r = m["GetOnly"];

            Assert.That(r, Is.EqualTo("abc"));
        }
Exemplo n.º 9
0
    public static void Test()
    {
        Console.WriteLine("Main Thread: {0}", Thread.CurrentThread.ManagedThreadId);
        var o = new TestSubject();

        Console.WriteLine("Property Value: {0}", o.IntGetValueNoSe());
    }
Exemplo n.º 10
0
        public void Can_get_chatMessages()
        {
            var firstWishList = new WishList {
                User         = new User(),
                ChatMessages =
                {
                    new ChatMessage {
                        Text = "Hello",
                        User = new User()
                    }
                }
            };
            var secondWishList = new WishList {
                User         = new User(),
                ChatMessages =
                {
                    new ChatMessage {
                        User = new User(),
                        Text = "Whatup"
                    }
                }
            };

            Context.AddRange(firstWishList, secondWishList);
            Context.SaveChanges();

            var result = TestSubject.Handle(new GetMessagesRequest {
                UserId     = 1,
                WishListId = firstWishList.Id
            });

            result.Messages.Select(m => m.Text).ShouldAllBeEquivalentTo(new[] {
                "Hello"
            });
        }
        public void FontListener_Get_ReturnsParsedAbsoluteFont()
        {
            // Given.
            var input    = "{7, 0, 0, 100, 0, 0, 0, 400, 1, 0, 1, 0,0,0,0,0, \"Arial\", 1, 120}";
            var expected = new AbsoluteFont
            {
                FaceName  = "Arial",
                Size      = 10,
                Bold      = false,
                Italic    = true,
                Underline = false,
                Strikeout = true,
                Scale     = 120,
            };

            var paser = CreateParser(input);
            var tree  = paser.font();

            WalkParseTree(tree);

            // When.
            var font = TestSubject.Get(tree);

            // Then.
            font.Should().BeOfType <AbsoluteFont>()
            .And.BeEquivalentTo(expected);
        }
Exemplo n.º 12
0
        public void PasswordTest()
        {
            TestSubject target   = new TestSubject();
            string      expected = null;

            Assert.AreEqual(expected, target.Password);
        }
Exemplo n.º 13
0
        public void ObjectPropertiesAreEqualShallReturnFalseWhenComparingTwoObjectsWithDifferingPropertyValues()
        {
            var testSubject1 = new TestSubject {
                Created = new DateTime(2010, 10, 1), Name = "testSubject1", Id = 1
            };
            var testSubject2 = new TestSubject {
                Created = new DateTime(2010, 10, 10), Name = "testSubject1", Id = 1
            };

            Assert.IsFalse(testSubject1.ObjectPropertiesAreEqual(testSubject2).AreEqual);

            testSubject1 = new TestSubject {
                Created = new DateTime(2010, 10, 10), Name = "testSubject1", Id = 1
            };
            testSubject2 = new TestSubject {
                Created = new DateTime(2010, 10, 10), Name = "testSubject2", Id = 1
            };

            Assert.IsFalse(testSubject1.ObjectPropertiesAreEqual(testSubject2).AreEqual);

            testSubject1 = new TestSubject {
                Created = new DateTime(2010, 10, 10), Name = "testSubject1", Id = 1
            };
            testSubject2 = new TestSubject {
                Created = new DateTime(2010, 10, 10), Name = "testSubject1", Id = 2
            };

            Assert.IsFalse(testSubject1.ObjectPropertiesAreEqual(testSubject2).AreEqual);
        }
Exemplo n.º 14
0
        public void EmailTest()
        {
            TestSubject target   = new TestSubject();
            string      expected = null;

            Assert.AreEqual(expected, target.Email);
        }
Exemplo n.º 15
0
        public OverloadSpec()
        {
            Describe("Method with overloads", () =>
            {
                It("should have all overloads covered by the one spy.", () =>
                {
                    var spy = Jaz.SpyOn(typeof(TestSubject), nameof(TestSubject.PositiveOne)).And.ReturnValues(3, 2, 1);

                    Expect(TestSubject.PositiveOne()).ToBe(3);
                    Expect(TestSubject.PositiveOne(0)).ToBe(2);
                    Expect(TestSubject.PositiveOne(0)).ToBe(1);
                });

                It("should record calls to both overloads.", () =>
                {
                    var spy = Jaz.SpyOn(typeof(TestSubject), nameof(TestSubject.Write));

                    TestSubject.Write(1, 2, 3);
                    TestSubject.Write(3);
                    TestSubject.Write(2, 3);

                    Expect(spy).ToHaveBeenCalledWith(2, 3);
                    Expect(spy).ToHaveBeenCalledWith(3);
                    Expect(spy).ToHaveBeenCalledWith(1, 2, 3);
                });
            });
        }
        public void FontListener_Get_ReturnsParsedAutoFont()
        {
            // Given.
            var input    = "{7, 3, 12, 700, 1, 1, 100}";
            var expected = new AutoFont
            {
                Bold   = true,
                Italic = true,
                Scale  = 100,
            };

            var parser = CreateParser(input);
            var tree   = parser.font();

            WalkParseTree(tree);

            // When.
            var font = TestSubject.Get(tree);

            // Then.
            font.Should().BeOfType <AutoFont>()
            .And.BeEquivalentTo(expected);

            TestSubject.Received(1)
            .FillRelativeFont((RelativeFont)font, tree.relativeFont());
        }
        public async Task <IHttpActionResult> PutTestSubject(Guid id, TestSubject testSubject)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != testSubject.Id)
            {
                return(BadRequest());
            }

            try
            {
                await testSubjectsRepository.PutTestSubject(id, testSubject);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!testSubjectsRepository.TestSubjectExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 18
0
        public void TestTypeResovlerForProxies()
        {
            var nested = new TestSubject();

            nested.SimpleString = "String in proxy";
            _subject.Proxy      = new Proxy(nested);
            try
            {
                object value = _reflection["Proxy.SimpleString"];
                Assert.Fail("Expected exception");
            }
            catch (ReflectionException Re)
            {
                Assert.That(Re.Message,
                            Text.StartsWith(ReflectionException.PropertyNotFound("SimpleString", typeof(Proxy)).Message));
            }
            _reflection.ObjectResolver = delegate(object source)
            {
                if (source is Proxy)
                {
                    return(((Proxy)source).Source);
                }
                else
                {
                    return(source);
                }
            };
            Assert.That(_reflection["Proxy.SimpleString"], Is.EqualTo("String in proxy"));
        }
Exemplo n.º 19
0
 public void Test1()
 {
     TestSubject ClassUnderTest = new TestSubject();
     ClassUnderTest.FunctionToTest1(0);
     ClassUnderTest.FunctionToTest1(1);
     ClassUnderTest.FunctionToTest1(5);
 }
    public ICollection <Experiment> Resolve(TestSubjectData source, TestSubject destination, ICollection <Experiment> destMember, ResolutionContext context)
    {
        var destExperiments = new List <Experiment>();

        if (source.Experiments == null)
        {
            return(destExperiments);
        }

        foreach (var experiment in source.Experiments)
        {
            var experimentToAdd = new Experiment()
            {
                Time          = experiment.Time,
                Comment       = experiment.Comment,
                TestSubjectId = experiment.TestSubject.Id.Value,
                GroupId       = experiment.GroupId,
                TaskId        = experiment.Task.Id.Value
            };

            if (experiment.Id != null)
            {
                experimentToAdd.Id = experiment.Id.Value;
            }

            destExperiments.Add(experimentToAdd);
        }
        return(destExperiments);
    }
Exemplo n.º 21
0
        void TestConvertReturnsEmptyListForResponseOfDifferentListTypeIfTheListIsEmpty()
        {
            List <IQueryResponseInterface> testResponse = new List <IQueryResponseInterface>();

            List <QueryResponse>?result = TestSubject.Convert(testResponse);

            Assert.True(!result.Any());
        }
Exemplo n.º 22
0
        public void Should_Find_Own_Getter_Only_Property_All_Getters()
        {
            var m = new TestSubject("abc");

            Assert.That(m["GetOnly"], Is.EqualTo("abc"));
            Assert.That(m.Get("GetOnly").Result, Is.EqualTo("abc"));
            Assert.That(m.TryGet("GetOnly"), Is.EqualTo("abc"));
        }
Exemplo n.º 23
0
        public void Should_Update_Set_FreeProperty_With_Reflection()
        {
            var r = new TestSubject();
            var m = new Reflection(r);

            m["Free"] = "Willy";
            Assert.That(r["Free"], Is.EqualTo("Willy"));
        }
Exemplo n.º 24
0
        public async Task ExcludeSameProduct()
        {
            var product = await TestSubject.GetAsync(3);

            var results = (await TestSubject.GetSuggestionsAsync(product, Products.SellMode.Downsell)).ToList();

            Assert.IsTrue(results.All(_ => _.ProductID != product.ProductID));
        }
Exemplo n.º 25
0
        public async Task OnlySameCategory()
        {
            var product = await TestSubject.GetAsync(1);

            var results = (await TestSubject.GetSuggestionsAsync(product, Products.SellMode.Downsell)).ToList();

            Assert.IsTrue(results.All(_ => _.Category == product.Category));
        }
Exemplo n.º 26
0
 public override void TestCleanup()
 {
     if (TestSubject != null)
     {
         TestSubject.Dispose(); TestSubject = null;
     }
     base.TestCleanup();
 }
Exemplo n.º 27
0
        public async Task OnlyReturnAvailable()
        {
            var product = await TestSubject.GetAsync(1);

            var results = (await TestSubject.GetSuggestionsAsync(product, Products.SellMode.Downsell)).ToList();

            Assert.IsTrue(results.All(_ => _.Available));
        }
Exemplo n.º 28
0
        public void Should_Update_Set_and_Get_Property_With_Nesting()
        {
            var m = new TestSubject();

            m["Free"]       = new Dictionary <string, object>();
            m["Free.Whale"] = "Willy";
            Assert.That(m["Free.Whale"], Is.EqualTo("Willy"));
        }
Exemplo n.º 29
0
 /// <summary>
 /// See <see cref="IDataStore"/> for method descriptions.
 /// </summary>
 public void AddSubject(TestSubject subject)
 {
     // A well designed UI should prevent this, but let's be safe.
     subject.Validate();
     datastore.Add(subject);
     // flush the updated dataset
     this.Flush();
 }
Exemplo n.º 30
0
    public void Test1()
    {
        TestSubject ClassUnderTest = new TestSubject();

        ClassUnderTest.FunctionToTest1(0);
        ClassUnderTest.FunctionToTest1(1);
        ClassUnderTest.FunctionToTest1(5);
    }
        void TestConvertReturnsSingleResponseAsIsForSubTypedResponse()
        {
            SubTypedQueryResponse testResponse = new SubTypedQueryResponse();

            QueryResponse?result = TestSubject.Convert(testResponse);

            Assert.Equal(testResponse, result);
        }
Exemplo n.º 32
0
        public void shouldInsertPipelineStepDirectly()
        {
            var obj = new TestSubject();
            var insertionScheme = new PipelineScheme(new[] { new StepMetadata("Bar", typeof(TestSubject), typeof(int), typeof(bool), "(0,0)") });

            var insertionTestee = new PipelineManager(insertionScheme);

            var result = insertionTestee.InsertPipelineStep<int, bool>(obj.Bar);

            Assert.IsTrue(result.Outcome == StepBuildResults.Completed);
        }
Exemplo n.º 33
0
 /// <exception cref="System.Exception"></exception>
 protected override void Store()
 {
     var subjectA = new TestSubject
         ("A", null);
     var subjectB = new TestSubject
         ("B", subjectA);
     var subjectC = new TestSubject
         ("C", subjectA);
     Store(subjectA);
     Store(subjectB);
     Store(subjectC);
 }
Exemplo n.º 34
0
        public void shouldGetAttributesForEachParameterInTestSubjectMethodInstance()
        {
            var testee = new TestSubject();
            var method = testee.GetType().GetMethod("Method");

            var expected = new[]
                {
                    new TestGeneratorParameterCasesAttribute(0, 1, 2),
                    new TestGeneratorParameterCasesAttribute('a', 'b', 2)
                };

            var actual = CodeGenerator.GetTestGeneratorAttributesForMethod(method);

            Assert.IsTrue(expected.SequenceEqual(actual), TestingHelpers.DumpTestSequencesToText(expected, actual));
        }
Exemplo n.º 35
0
        public void TestGetsShouldBeCamelCased()
        {
            var subject = new TestSubject();
            var reflection = new Reflection(subject).AdaptToNaturalLanguage();
            subject.ComplexArray = new TestSubject[3];
            subject.ComplexArray[0] = new TestSubject();
            subject.ComplexArray[1] = new TestSubject();
            subject.ComplexArray[2] = new TestSubject();
            subject.ComplexArray[0].SimpleString = "first";
            subject.ComplexArray[1].SimpleString = "second";
            subject.ComplexArray[2].SimpleString = "third";

            Assert.That(reflection.Get("complex array.0.simple string").Result, Is.EqualTo("first"));
            Assert.That(reflection.Get("complex array.1.simple string").Result, Is.EqualTo("second"));
            Assert.That(reflection.Get("complex array.2.simple string").Result, Is.EqualTo("third"));
        }
Exemplo n.º 36
0
        public void shouldWriteExpectedTestCode()
        {
            var testee = new TestSubject();
            var methodInfo = testee.GetType().GetMethod("Add2And2");

            var expected =
            @"var expected = 4;

            var actual = testee.Add2And2();

            Assert.IsTrue(expected.Equals(actual));";

            var actual = CodeGenerator.CreateTestMethodCodeFor(methodInfo, null, 4);

            Assert.IsTrue(expected.Equals(actual, StringComparison.InvariantCultureIgnoreCase));
        }
Exemplo n.º 37
0
        public void TestSetsByIndexerShouldBeCamelCased()
        {
            var subject = new TestSubject();
            var reflection = new Reflection(subject).AdaptToNaturalLanguage();
            subject.ComplexArray = new TestSubject[3];
            subject.ComplexArray[0] = new TestSubject();
            subject.ComplexArray[1] = new TestSubject();
            subject.ComplexArray[2] = new TestSubject();
            subject.ComplexArray[0].SimpleString = "first";
            subject.ComplexArray[1].SimpleString = "second";
            subject.ComplexArray[2].SimpleString = "third";

            reflection["complex array.0.simple string"] = "1 CHANGED";
            reflection["complex array.1.simple string"] = "2 CHANGED";
            reflection["complex array.2.simple string"] = "3 CHANGED";

            Assert.That(subject.ComplexArray[0].SimpleString, Is.EqualTo("1 CHANGED"));
            Assert.That(subject.ComplexArray[1].SimpleString, Is.EqualTo("2 CHANGED"));
            Assert.That(subject.ComplexArray[2].SimpleString, Is.EqualTo("3 CHANGED"));
        }
Exemplo n.º 38
0
 public void SetUp()
 {
     _model = new TestModel();
     _router = new Router<TestModel>(_model, RouterScheduler.Default);
     _asyncSubject = new TestSubject<string>();
 }
Exemplo n.º 39
0
 public TestSubject(string name, TestSubject child)
 {
     _name = name;
     _child = child;
 }