public void Update()
        {
            var course = DemoCourse(Guid.NewGuid().ToString());

            using (var session = new SqliteUnitOfWorkSession(Connection))
            {
                session.Add(course);
                session.Commit().ShouldBeSuccessful();
            }

            var dbCourse = Connection.Find <Course>(course.Id);

            dbCourse.ShouldNotBeNull();
            dbCourse.Title.ShouldBe(course.Title);

            dbCourse.Title = Guid.NewGuid().ToString();
            dbCourse.Title.ShouldNotBe(course.Title);

            using (var session = new SqliteUnitOfWorkSession(Connection))
            {
                session.Update(dbCourse);
                session.Commit().ShouldBeSuccessful();
            }

            var dbCourse2 = Connection.Find <Course>(course.Id);

            dbCourse2.ShouldNotBeNull();
            dbCourse2.Title.ShouldBe(dbCourse.Title);
        }
Beispiel #2
0
        public void All()
        {
            var course1 = DemoCourse("1");
            var course2 = DemoCourse("2");
            var course3 = DemoCourse("3");

            using (var session = new SqliteUnitOfWorkSession(Connection))
            {
                session.Add(course1);
                session.Add(course2);
                session.Add(course3);

                session.Commit().ShouldBeSuccessful();
            }

            var connection = Substitute.For <IDbConnection>();

            connection.Connection.Returns(Connection);

            var sut    = new SqliteCourseRepository(connection);
            var result = sut.All();

            result.ShouldNotBeNull();

            result.ShouldContain(course1);
            result.ShouldContain(course2);
            result.ShouldContain(course3);
        }