Exemple #1
0
        public void assure_object_graph_is_Serialized_correctly()
        {
            DataContractSerializer serializer = new DataContractSerializer(typeof(IEnumerable<Changeset>), null, int.MaxValue, false, false, null);


            ChangesetServer server = new ChangesetServer() { Name = "Test name", Url = "http://www.smeedee.org" };
            Changeset changeset = new Changeset() { Server = server, Comment = "SmeeDee", Revision = 1001, Author = new Author("tuxbear")};
            Changeset changeset2 = new Changeset() { Server = server, Comment = "SmeeDee2", Revision = 1002, Author = new Author("tuxbear")};
            
            server.Changesets.Add(changeset);
            server.Changesets.Add(changeset2);
            

            MemoryStream stream = new MemoryStream();

            serializer.WriteObject(stream, new [] {changeset, changeset2});
            stream.Position = 0;

            object deSerialized = serializer.ReadObject(stream);

            var changesets = deSerialized as IEnumerable<Changeset>;
            var firstDeserialized = changesets.ElementAt(0);
            firstDeserialized.Revision.ShouldBe(1001);
            var secondDeserialized = changesets.ElementAt(1);
            secondDeserialized.Revision.ShouldBe(1002);
        }
Exemple #2
0
        public void Assure_has_revision()
        {
            var cs = new Changeset();
            Assert.AreEqual(cs.Revision, 0);

            cs.Revision = 1;
            Assert.AreEqual(cs.Revision, 1);
        }
Exemple #3
0
        public void Assure_has_message()
        {
            var cs = new Changeset();
            Assert.IsNull(cs.Comment);

            const string log = "This is a log message!";
            cs.Comment = log;
            Assert.AreEqual(cs.Comment, log);
        }
Exemple #4
0
        public void Assure_has_datetime()
        {
            var cs = new Changeset();
            Assert.IsNotNull(cs.Time);

            var date = new DateTime(1986, 04, 12);
            cs.Time = date;
            Assert.AreEqual(cs.Time, date);
        }
Exemple #5
0
        public void Assure_has_author()
        {
            var cs = new Changeset();
            Assert.IsNull(cs.Author);

            var user = new Author {Username = "******"};
            cs.Author = user;
            Assert.AreEqual(cs.Author, user);
        }
        public void Should_be_satisfied_by_Changesets_with_newer_Revision()
        {
            var changeset = new Changeset();
            changeset.Revision = 1001;

            specification.IsSatisfiedBy(changeset).ShouldBeTrue();

            changeset.Revision = 999;

            specification.IsSatisfiedBy(changeset).ShouldBeFalse();
        }
        public void Should_be_satisfied_by_Changesets_with_same_Author_as_Username()
        {
            var changeset = new Changeset();
            changeset.Author = new Author();
            changeset.Author.Username = "******";

            specification.IsSatisfiedBy(changeset).ShouldBeTrue();

            changeset.Author.Username = "******";

            specification.IsSatisfiedBy(changeset).ShouldBeFalse();

        }
Exemple #8
0
 public void Assure_returns_good_log_when_not_empty()
 {
     var cs = new Changeset
              {
                  Comment = "Added tests for SC domain model."
              };
     Assert.IsTrue(cs.IsValidComment());
 }
Exemple #9
0
 public void Assure_returns_bad_log_when_empty()
 {
     var cs = new Changeset();
     Assert.IsFalse(cs.IsValidComment());
 }
        public void Assure_Changeset_is_saved()
        {
            var changeset = new Changeset
                            {
                                Author = new Author { Username = TEST_USERNAME },
                                Comment = TEST_COMMENT,
                                Revision = TEST_REVISION_NUMBER,
                                Time = TEST_TIME
                            };

            repository.Save(changeset);

            ISessionFactory newSessionFactory = NHibernateFactory.AssembleSessionFactory(DATABASE_TEST_FILE);

            var dbResults = DatabaseRetriever.GetDatamodelFromDatabase<Changeset>(newSessionFactory);

            dbResults[0].Author.Username.ShouldBe(TEST_USERNAME);
            dbResults[0].Comment.ShouldBe(TEST_COMMENT);
            dbResults[0].Revision.ShouldBe(TEST_REVISION_NUMBER);
            dbResults[0].Time.ShouldBe(TEST_TIME);
        }