public void GetInstanceResolveStateIsPersistent()
        {
            var adapter = AdapterFor(GetPerson(1));

            Assert.IsTrue(adapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(adapter.Oid.IsTransient, "is transient");
        }
Ejemplo n.º 2
0
 public void One()
 {
     Assert.IsTrue(IQ.From("select * FROM animals where pk=3").One());
     Assert.IsFalse(IQ.From("select * FROM animals").One());
     Assert.IsFalse(IQ.From("select * FROM animals where pk=99999").One());
     Assert.IsFalse(IQ.From("select * FROM animals where pk<10").One());
 }
        public void ReferencePropertyObjectResolveStateIsPersistent()
        {
            var adapter = AdapterFor(GetProductFromPersonOne());

            Assert.IsTrue(adapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(adapter.Oid.IsTransient, "is transient");
        }
Ejemplo n.º 4
0
        public void DoesNotMatchStaticField()
        {
            ObjectWithFields o = new ObjectWithFields();
            Matcher          m = new FieldMatcher("StaticField", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field is static");
        }
        public void CollectionPropertyObjectResolveStateIsPersistent()
        {
            var adapter = AdapterFor(GetPersonFromPersonOneCollection());

            Assert.IsTrue(adapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(adapter.Oid.IsTransient, "is transient");
        }
Ejemplo n.º 6
0
        public void DoesNotMatchObjectIfItDoesNotHaveNamedField()
        {
            ObjectWithFields o = new ObjectWithFields();
            Matcher          m = new FieldMatcher("FavouriteColour", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field does not exist");
        }
Ejemplo n.º 7
0
        public void DoesNotMatchInvocationWithDifferentNumberOfArguments()
        {
            Matcher matcher = new ArgumentsMatcher(Is.Anything, Is.Anything);

            Assert.IsFalse(matcher.Matches(InvocationWithArguments(1)), "fewer arguments");
            Assert.IsFalse(matcher.Matches(InvocationWithArguments(1, 2, 3)), "more arguments");
        }
        public void SaveNewObjectWithTransientCollectionItem()
        {
            var person1 = CreateNewTransientPerson();
            var person2 = CreateNewTransientPerson();

            person1.Name = Guid.NewGuid().ToString();
            person2.Name = Guid.NewGuid().ToString();
            person1.Relatives.Add(person2);
            var person1Adapter = Save(person1);

            // use new person to avoid EF quirk
            person1 = person1Adapter.GetDomainObject <Person>();
            person2 = person1.Relatives.Single();
            Assert.IsTrue(person1Adapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(person1Adapter.Oid.IsTransient, "is transient");
            var person2Adapter = AdapterFor(person2);

            Assert.IsTrue(person2Adapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(person2Adapter.Oid.IsTransient, "is transient");

            var collectionAdapter = ((IObjectSpec)person1Adapter.Spec).GetProperty("Relatives").GetNakedObject(person1Adapter);

            Assert.IsTrue(collectionAdapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(collectionAdapter.ResolveState.IsGhost(), "should not be ghost");
        }
Ejemplo n.º 9
0
        public void Basic()
        {
            //Assert.Throws<Exception>(() => {
            //    TestObjectBugs testBugs = new TestObjectBugs();

            //}, "Can't create instance of primary-keyless object");

            var test = new TestObject();

            IQ.Track(test);

            Assert.IsFalse(test.IsDirty(), "New object isn't dirty");
            Assert.IsTrue(test.IsNew(), "New object is new");

            test.FirstName = "Jamie";
            Assert.IsTrue(test.IsDirty("FirstName"), "Changing name dirtied it");
            Assert.IsTrue(test.IsDirty(), "Changing a field dirtied the whole object");

            int dirtyCount = 0;

            foreach (var item in test.DirtyFieldNames())
            {
                dirtyCount++;
                Assert.AreEqual("FirstName", item, "The field that's dirty is firstname");
            }
            Assert.AreEqual(1, dirtyCount, "There was one dirty field");
        }
        public void GetInlineInstance()
        {
            var addressAdapter = GetAdaptedAddress(GetPerson(1));

            Assert.IsTrue(addressAdapter.ResolveState.IsPersistent(), "should be persistent");
            Assert.IsFalse(addressAdapter.Oid.IsTransient, "is transient");
        }
Ejemplo n.º 11
0
        public void MatchesNullReferences()
        {
            Matcher matcher = new NullMatcher();

            Assert.IsTrue(matcher.Matches(null), "null");
            Assert.IsFalse(matcher.Matches(new object()), "not null");
        }
        public void SenseitiveData_NestedObj()
        {
            var obj = new NestedObjWithSensitive()
            {
                OHay            = "test",
                SomethingElse   = "bbbbb",
                ThisIsSensitive = "88888",
                ASensitiveList  = new List <string>()
                {
                    "99999",
                    "221212"
                },
                ThisHasSomeSensitiveFields = new RequiredFieldDerived()
                {
                    BaseIntegerType    = 5,
                    BaseStringType     = "asdasd",
                    DerivedIntegerType = 33,
                    DerivedStringType  = "xxxx",
                    SensitiveInt       = 1111,
                    SensitiveString    = "yyyy"
                }
            };

            var res = obj.ObjToJson();

            Assert.IsFalse(res.Contains("yyyy"));
            Assert.IsFalse(res.Contains("1111"));
            Assert.IsFalse(res.Contains("88888"));
            Assert.IsFalse(res.Contains("99999"));
            Assert.IsFalse(res.Contains("221212"));
        }
Ejemplo n.º 13
0
        public void Any()
        {
            var table = IQ.From <Cat>();

            Assert.IsTrue(table.Where("pk<10").Any());
            Assert.IsFalse(table.Where("pk=99999").Any());
        }
 public void SaveNewObjectWithScalars() {
     var person = CreateNewTransientPerson();
     person.Name = Guid.NewGuid().ToString();
     var adapter = Save(person);
     Assert.IsTrue(adapter.ResolveState.IsPersistent(), "should be persistent");
     Assert.IsFalse(adapter.Oid.IsTransient, "is transient");
 }
Ejemplo n.º 15
0
        public void FindHypotenuseValidateInputs()
        {
            var error = false;

            try
            {
                // Make sure side 1 is valid
                Pythagorean.FindHypotenuse(0, 2);
                error = true;
            }
            catch
            {
                // ignored
            }

            try
            {
                // Make sure side 2 is valid
                Pythagorean.FindHypotenuse(2, 0);
                error = true;
            }
            catch
            {
                // ignored
            }

            Assert.IsFalse(error, "We should have thrown errors above");
        }
Ejemplo n.º 16
0
        public void EditSubmissionThesisTest()
        {
            IDao dao = new DatabaseManager();

            SubmissionThesis submission = new SubmissionThesis();

            submission.SubmissionId     = 1;
            submission.ThesisTopic      = "Tresc";
            submission.TopicNumber      = 2;
            submission.ThesisObjectives = "Cele pracy";
            submission.ThesisScope      = "Cele pracy";
            submission.Status           = ThesisStatus.APPROVED;
            FinalThesis finalThesis = new FinalThesis();

            finalThesis.FinalThesisId = 1;
            submission.FinalThesis    = finalThesis;
            Edition edition = new Edition();

            edition.Number     = 1;
            submission.Edition = edition;

            Assert.IsTrue(dao.EditSubmissionThesis(submission));
            submission.SubmissionId = 100000;
            Assert.IsFalse(dao.EditSubmissionThesis(submission));

            try
            {
                SubmissionThesis incorrectSubmission = new SubmissionThesis();
                incorrectSubmission.SubmissionId = -1;
                dao.EditSubmissionThesis(incorrectSubmission);
                Assert.Fail();
            }
            catch (ArgumentException) { }
        }
Ejemplo n.º 17
0
        public void CanCompareAutoboxedValues()
        {
            Matcher matcher = new EqualMatcher(1);

            Assert.IsTrue(matcher.Matches(1), "equal value");
            Assert.IsFalse(matcher.Matches(2), "other value");
        }
Ejemplo n.º 18
0
        public void Queen_QueenNotOnSameRowOrColumn_IsNotAttacking(int q1Row, int q1Column, int q2Row, int q2Column)
        {
            var q1 = new Queen(q1Row, q1Column);
            var q2 = new Queen(q2Row, q2Column);

            Assert.IsFalse(q1.IsAttacking(q2));
        }
Ejemplo n.º 19
0
        public IEnumerator JohnCanLogOut()
        {
            yield return(OnFacet <AuthenticationFacet> .Call(
                             nameof(AuthenticationFacet.Login),
                             "John"
                             ).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call(
                             nameof(AuthenticationFacet.Logout)
                             ).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <PlayerEntity>(
                             nameof(AuthenticationFacet.GetPlayer)
                             ).Then(p => {
                Assert.IsNull(p);
            }).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <bool>(
                             nameof(AuthenticationFacet.Check)
                             ).Then(c => {
                Assert.IsFalse(c);
            }).AsCoroutine());

            yield return(OnFacet <AuthenticationFacet> .Call <string>(
                             nameof(AuthenticationFacet.Id)
                             ).Then(id => {
                Assert.IsNull(id);
            }).AsCoroutine());
        }
Ejemplo n.º 20
0
        public void MatchesCallCountWhenMatchingInvocation()
        {
            Matcher irrelevant = Is.Anything;

            BuildableExpectation expectation = (BuildableExpectation)BuildExpectation(
                "description",
                Is.AtLeast(0),
                Is.AtMost(4),
                receiver.MockObject,
                irrelevant,
                irrelevant,
                irrelevant,
                irrelevant);

            AssertIsActive(expectation, "should be active before any invocation");
            Assert.IsTrue(expectation.Matches(invocation), "should match 1st invocation");
            expectation.Perform(invocation);

            AssertIsActive(expectation, "should be active before 2nd invocation");
            Assert.IsTrue(expectation.Matches(invocation), "should match 2nd invocation");
            expectation.Perform(invocation);

            AssertIsActive(expectation, "should be active before 3rd invocation");
            Assert.IsTrue(expectation.Matches(invocation), "should match 3rd invocation");
            expectation.Perform(invocation);

            AssertIsActive(expectation, "should be active before 4th invocation");
            Assert.IsTrue(expectation.Matches(invocation), "should match 4th invocation");
            expectation.Perform(invocation);

            AssertIsNotActive(expectation, "should not be active after 4th invocation");
            Assert.IsFalse(expectation.Matches(invocation), "should not match 5th invocation");
        }
Ejemplo n.º 21
0
        public void FailHitTests()
        {
            // new ship
            var ship = new Ship(new[] {4, 5, 3});

            Assert.IsFalse(ship.Hit(6));
            Assert.IsTrue(ship.IsAlive);
        }
Ejemplo n.º 22
0
        public void DoesNotMatchObjectIfItDoesNotHaveNamedProperty()
        {
            ObjectWithProperties o = new ObjectWithProperties();

            Matcher m = new PropertyMatcher("OtherProperty", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o");
        }
Ejemplo n.º 23
0
        public void DoesNotMatchValueOfNonAssignableType()
        {
            Matcher m = new TypeMatcher(typeof(D));

            Assert.IsFalse(m.Matches(new B()), "should not match B");
            Assert.IsFalse(m.Matches(123), "should not match B");
            Assert.IsFalse(m.Matches("hello, world"), "should not match B");
        }
Ejemplo n.º 24
0
        public static void False(bool condition)
        {
#if XUNIT
            FrameworkAssert.False(condition);
#else
            FrameworkAssert.IsFalse(condition);
#endif
        }
Ejemplo n.º 25
0
        public void DoesNotMatchWriteOnlyProperty()
        {
            ObjectWithProperties o = new ObjectWithProperties();

            Matcher m = new PropertyMatcher("WriteOnlyProperty", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o");
        }
Ejemplo n.º 26
0
        public void DelegatesMatchingToAnotherMatcher()
        {
            Matcher m1 = new DescriptionOverride("irrelevant", new AlwaysMatcher(true, "always true"));
            Matcher m2 = new DescriptionOverride("irrelevant", new AlwaysMatcher(false, "always false"));

            Assert.IsTrue(m1.Matches(new object()), "m1");
            Assert.IsFalse(m2.Matches(new object()), "m2");
        }
Ejemplo n.º 27
0
        public void IsEmpty()
        {
            var item = new WhereClause();

            Assert.IsTrue(item.IsEmpty);

            item.Add(new WhereString("a=b"));
            Assert.IsFalse(item.IsEmpty);
        }
Ejemplo n.º 28
0
        public void DoesNotMatchIfValueMatchersDoNotMatchArgumentValues()
        {
            Matcher matcher = new ArgumentsMatcher(Is.EqualTo(arg1Value), Is.EqualTo(arg2Value));

            Assert.IsFalse(matcher.Matches(InvocationWithArguments("other object", arg2Value)),
                           "different first arg");
            Assert.IsFalse(matcher.Matches(InvocationWithArguments(arg1Value, "other object")),
                           "different second arg");
        }
Ejemplo n.º 29
0
        public void MatchesMethodsWithAGivenName()
        {
            Matcher matcher = new MethodNameMatcher("m", typeof(I));

            Assert.IsTrue(matcher.Matches(typeof(I).GetMethod("m", new Type[0])), "m()");
            Assert.IsTrue(matcher.Matches(typeof(I).GetMethod("m", new[] { typeof(int) })), "m(int)");
            Assert.IsTrue(matcher.Matches(typeof(I).GetMethod("m", new[] { typeof(string), typeof(string) })), "m(string,string)");
            Assert.IsFalse(matcher.Matches(typeof(I).GetMethod("n", new Type[0])), "n()");
        }
Ejemplo n.º 30
0
        public void DoesNotMatchObjectIfValueMatcherDoesNotMatch()
        {
            ObjectWithFields o = new ObjectWithFields();

            o.PublicField = "actual value";
            Matcher m = new FieldMatcher("PublicField", new EqualMatcher("some other value"));

            Assert.IsFalse(m.Matches(o), "should match o; value is different");
        }