Example #1
0
            public async Task WhenSomeEmailAddressesAreInvalid_ItShouldCallUpdateFreeAccessUsersAndItShouldReturnValidEmailAddresses()
            {
                var emailList = new List <string> {
                    "*****@*****.**", "two.test.com"
                };
                var freeAccessUsersData = new FreeAccessUsersData {
                    Emails = emailList
                };

                var validEmailList = new List <ValidEmail> {
                    ValidEmail.Parse(emailList[0])
                };
                var invalidEmailList = new List <Email> {
                    new Email(emailList[1])
                };

                var expectedResult = new PutFreeAccessUsersResult(invalidEmailList);

                this.updateFreeAccessUsers
                .Setup(v => v.HandleAsync(new UpdateFreeAccessUsersCommand(Requester, BlogId, validEmailList)))
                .Returns(Task.FromResult(0))
                .Verifiable();

                var result = await this.target.PutFreeAccessList(BlogId.Value.EncodeGuid(), freeAccessUsersData);

                this.updateFreeAccessUsers.Verify();
                Assert.AreEqual(expectedResult, result);
            }
Example #2
0
            public async Task WhenDuplicateEmailsAreInvalid_ItDeDuplicateBeforeReturningInvalidEmails()
            {
                var emailList = new List <string> {
                    "one.test.com", "one.test.com"
                };
                var freeAccessUsersData = new FreeAccessUsersData {
                    Emails = emailList
                };

                var validEmailList   = new List <ValidEmail>();
                var invalidEmailList = new List <Email> {
                    new Email(emailList[0])
                };

                var expectedResult = new PutFreeAccessUsersResult(invalidEmailList);

                this.updateFreeAccessUsers
                .Setup(v => v.HandleAsync(new UpdateFreeAccessUsersCommand(Requester, BlogId, validEmailList)))
                .Returns(Task.FromResult(0))
                .Verifiable();

                var result = await this.target.PutFreeAccessList(BlogId.Value.EncodeGuid(), freeAccessUsersData);

                this.updateFreeAccessUsers.Verify();
                Assert.AreEqual(expectedResult, result);
            }