Exemplo n.º 1
0
        public async Task AddSocialization_ShouldDoNotWorkCorrectlyIfDestinationDoNotExist()
        {
            var destUsersAll = new List <DestinationsUsers>()
            {
                new DestinationsUsers()
                {
                    DestinationId = "1",
                    ParticipantId = "2"
                }
            }.AsQueryable();

            var destUsersRepoMock = new Mock <IRepository <DestinationsUsers> >();

            destUsersRepoMock.Setup(d => d.All())
            .Returns(destUsersAll).Verifiable();

            var sut = new DestinationService(null, destUsersRepoMock.Object, null, null, null, null, null, null);

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await sut.AddSocialization(new GoUser()
            {
                Id = "2"
            }, "5", "KnowSomeone"));

            ex.Message.ShouldBe("You are not in this group.");
            destUsersRepoMock.Verify();
        }
Exemplo n.º 2
0
        public async Task AddSocialization_ShouldWorkCorrectly()
        {
            var destUsersAll = new List <DestinationsUsers>()
            {
                new DestinationsUsers()
                {
                    DestinationId = "1",
                    ParticipantId = "2"
                }
            }.AsQueryable();

            var destUsersRepoMock = new Mock <IRepository <DestinationsUsers> >();

            destUsersRepoMock.Setup(d => d.All())
            .Returns(destUsersAll).Verifiable();

            var sut = new DestinationService(null, destUsersRepoMock.Object, null, null, null, null, null, null);

            await sut.AddSocialization(new GoUser()
            {
                Id = "2"
            }, "1", "KnowSomeone");

            destUsersRepoMock.Verify();
            destUsersRepoMock.Verify(r => r.SaveChangesAsync(), Times.Once);
        }