예제 #1
0
        public void test_repository_Mocking()
        {
            var userAccounts = new List <UserAccount>
            {
                new UserAccount
                {
                    AccountId       = Guid.Parse("3A557B7B-073F-4CCA-B834-CDA95850213E"),
                    CorrelationGuid = Guid.Parse("3A557B7B-073F-4CCA-B834-CDA95850213E"),
                    LoginEmail      = "*****@*****.**"
                },
                new UserAccount
                {
                    AccountId       = Guid.Parse("07971F9F-14D8-4127-A5F8-D1B77DCBC218"),
                    CorrelationGuid = Guid.Parse("07971F9F-14D8-4127-A5F8-D1B77DCBC218"),
                    LoginEmail      = "*****@*****.**"
                }
            };

            var userAccountRepositoryMock = new Mock <IAccountRepository>();

            userAccountRepositoryMock.Setup(obj => obj.Get()).Returns(userAccounts);

            var repositoryTestClass = new RepositoryTestClass(userAccountRepositoryMock.Object);

            var result = repositoryTestClass.GetAccounts();

            Assert.IsTrue(Equals(userAccounts, result), "List from repository does not match the class passed into the mock");
        }
예제 #2
0
        public void test_repository_Usage_Integration()
        {
            var repositoryTestClass = new RepositoryTestClass();
            var accounts            = repositoryTestClass.GetAccounts();

            Assert.IsTrue(accounts != null, "accounts is null");
        }