Ejemplo n.º 1
0
        public void Test_AddAndGetMembers()
        {
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                new UsersRepository(_connectionString),
                new PlacesRepository(_connectionString)
                );

            var user1 = TestHelper.GenerateTestUser();
            var user2 = TestHelper.GenerateTestUser();
            var owner = TestHelper.GenerateTestUser();
            meetingRepository.UsersRepository.Create(user1);
            meetingRepository.UsersRepository.Create(user2);
            meetingRepository.UsersRepository.Create(owner);

            var place = TestHelper.GenerateTestPlace();
            meetingRepository.PlacesRepository.Create(place);

            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Title = "title",
                Place = place,
                Owner = owner
            };
            meetingRepository.Create(meeting);
            //act
            meetingRepository.AddMember(meeting.Id, user1.Id);
            meetingRepository.AddMember(meeting.Id, user2.Id);
            var members = meetingRepository.GetMembers(meeting.Id);
            //asserts
            Assert.IsTrue(members.Count() == 3);
        }
Ejemplo n.º 2
0
        public void Test_CreateAndGetMeet()
        {
            //arrange
            var usersRepository = new Mock<UsersRepository>(_connectionString) { CallBase = true };
            usersRepository.Setup(t => t.Get(It.IsAny<Guid>())).Returns(new User());

            var placesRepository = new Mock<PlacesRepository>(_connectionString) { CallBase = true };
            placesRepository.Setup(t => t.Get(It.IsAny<Guid>())).Returns(new Place());

            var meetingRepository = new MeetingsRepository(
                _connectionString,
                usersRepository.Object,
                placesRepository.Object
                );

            var user = TestHelper.GenerateTestUser();
            meetingRepository.UsersRepository.Create(user);
            var place = TestHelper.GenerateTestPlace();
            meetingRepository.PlacesRepository.Create(place);
            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Owner = user,
                Place = place,
                Title = "titlemeet"
            };

            //act
            meetingRepository.Create(meeting);
            var resultMeet = meetingRepository.Get(meeting.Id);

            //asserts
            Assert.IsTrue(meeting.Title == resultMeet.Title);
        }
Ejemplo n.º 3
0
        public void Test_UpdateMeeting()
        {
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                new UsersRepository(_connectionString),
                new PlacesRepository(_connectionString)
                );

            var user = TestHelper.GenerateTestUser(Guid.NewGuid());
            meetingRepository.UsersRepository.Create(user);

            var place = TestHelper.GenerateTestPlace(Guid.NewGuid());
            meetingRepository.PlacesRepository.Create(place);

            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Owner = user,
                Place = place,
                Title = "titlemeet"
            };
            var updMeeting = new Meeting
            {
                Id = meeting.Id,
                Owner = user,
                Place = place,
                Title = "newtitlemeet"
            };
            //act
            meetingRepository.Create(meeting);
            meetingRepository.Update(updMeeting);
            //asserts
            Assert.IsTrue(updMeeting.Owner.Id.Equals(meetingRepository.Get(meeting.Id).Owner.Id));
        }
Ejemplo n.º 4
0
 public void Test_GetNotExistingMeeting()
 {
     //arrange
     var meetingRepository = new MeetingsRepository(
         _connectionString,
         new UsersRepository(_connectionString),
         new PlacesRepository(_connectionString)
         );
     //act
     meetingRepository.Get(Guid.NewGuid());
 }
Ejemplo n.º 5
0
        public void Test_GetAllMeetings()
        {
            var usersRepository = new Mock<UsersRepository>(_connectionString) { CallBase = true };
            usersRepository.Setup(t => t.Get(It.IsAny<Guid>())).Returns(new User());

            var placesRepository = new Mock<PlacesRepository>(_connectionString) { CallBase = true };
            placesRepository.Setup(t => t.Get(It.IsAny<Guid>())).Returns(new Place());
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                usersRepository.Object,
                placesRepository.Object
                );

            var owner1 = TestHelper.GenerateTestUser();
            meetingRepository.UsersRepository.Create(owner1);
            var place1 = TestHelper.GenerateTestPlace();
            meetingRepository.PlacesRepository.Create(place1);
            var meeting1 = new Meeting
            {
                Id = Guid.NewGuid(),
                Owner = owner1,
                Place = place1,
                Title = "titlemeet"
            };
            meetingRepository.Create(meeting1);

            var owner2 = TestHelper.GenerateTestUser();
            meetingRepository.UsersRepository.Create(owner2);
            var place2 = TestHelper.GenerateTestPlace();
            meetingRepository.PlacesRepository.Create(place2);
            var meeting2 = new Meeting
            {
                Id = Guid.NewGuid(),
                Owner = owner2,
                Place = place2,
                Title = "titlemeet"
            };
            meetingRepository.Create(meeting2);

            //act
            var meetings = meetingRepository.GetAllMeetings();
            //arrange
            Assert.IsTrue(meetings.Count() == 2);
        }
Ejemplo n.º 6
0
        public void Test_DeleteMember()
        {
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                new UsersRepository(_connectionString),
                new PlacesRepository(_connectionString)
                );

            var user1 = TestHelper.GenerateTestUser(Guid.NewGuid());
            meetingRepository.UsersRepository.Create(user1);

            var owner = TestHelper.GenerateTestUser(Guid.NewGuid());
            meetingRepository.UsersRepository.Create(owner);

            var place = TestHelper.GenerateTestPlace(Guid.NewGuid());
            meetingRepository.PlacesRepository.Create(place);

            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Title = "title",
                Place = place,
                Owner = owner
            };
            meetingRepository.Create(meeting);

            meetingRepository.AddMember(meeting.Id, user1.Id);
            //act
            meetingRepository.DeleteMember(meeting.Id, user1.Id);
            //assert
            var members = meetingRepository.GetMembers(meeting.Id);
            Assert.IsFalse(members.Contains(user1));
        }
Ejemplo n.º 7
0
        public void Test_DeleteMeeting()
        {
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                new UsersRepository(_connectionString),
                new PlacesRepository(_connectionString)
                );
            var user = TestHelper.GenerateTestUser(Guid.NewGuid());
            meetingRepository.UsersRepository.Create(user);

            var place = TestHelper.GenerateTestPlace(Guid.NewGuid());
            meetingRepository.PlacesRepository.Create(place);

            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Title = "title",
                Owner = user,
                Place = place

            };
            meetingRepository.Create(meeting);
            //act
            meetingRepository.Delete(meeting.Id);
            //asserts
            meetingRepository.Get(meeting.Id);
        }
Ejemplo n.º 8
0
        public void Test_CreateMeetingTwice()
        {
            //arrange
            var meetingRepository = new MeetingsRepository(
                _connectionString,
                new UsersRepository(_connectionString),
                new PlacesRepository(_connectionString)
                );

            var user = TestHelper.GenerateTestUser();
            meetingRepository.UsersRepository.Create(user);
            var place = TestHelper.GenerateTestPlace();
            meetingRepository.PlacesRepository.Create(place);
            var meeting = new Meeting
            {
                Id = Guid.NewGuid(),
                Owner = user,
                Place = place,
                Title = "titlemeet"
            };
            meetingRepository.Create(meeting);
            //act
            meetingRepository.Create(meeting);
        }