public void Setup()
        {
            _commandFactory = SetupMock <ICommandFactory>();
            _contextFactory = SetupMock <IContextFactory>();

            var usersTable = new JArray();

            usersTable.Add(JObject.Parse("{userId:1,userName:\"martin\"}"));
            usersTable.Add(JObject.Parse("{userId:2,userName:\"wilson\"}"));
            usersTable.Add(JObject.Parse("{userId:3,userName:\"daisy\"}"));
            usersTable.Add(JObject.Parse("{userId:4,userName:\"nancy\"}"));

            var productTable = new JArray();

            productTable.Add(JObject.Parse("{productId:1,sku:\"abc45324\"}"));
            productTable.Add(JObject.Parse("{productId:2,sku:\"gtf34355\"}"));
            productTable.Add(JObject.Parse("{productId:3,sku:\"iuo76573\"}"));
            productTable.Add(JObject.Parse("{productId:4,sku:\"zer76576\"}"));

            var mockedRepository = new MockedRepository("MyData");

            mockedRepository.Add("sp_GetAllUsers", usersTable);
            mockedRepository.Add("sp_GetUser", new GetUserProcedure(usersTable));
            mockedRepository.Add("sp_CreateUser", new CraeteUserProcedure(usersTable));
            mockedRepository.Add("sp_DeleteUser", new DeleteUserProcedure(usersTable));

            var mockContextFactory = GetMock <MockContextFactory, IContextFactory>();

            mockContextFactory.MockedRepository = mockedRepository;
        }
Example #2
0
        public void Setup()
        {
            _commandFactory = SetupMock <ICommandFactory>();

            _context = new Context(
                SetupMock <IDataEnumeratorFactory>(),
                SetupMock <IErrorReporter>(),
                SetupMock <IRepository>());

            var mockedRepository = new MockedRepository("MyData");

            mockedRepository.Add("proc1", JArray.Parse("[{id:10,name:\"name1\"},{id:20,name:\"name2\"}]"));

            var mockConnectionFactory = GetMock <MockConnectionFactory, IConnectionFactory>();

            mockConnectionFactory.MockedRepository = mockedRepository;
        }
        public void Setup()
        {
            var tables = new Dictionary <string, JArray>();

            tables.Add("identity", new JArray());
            tables.Add("credentials", new JArray());
            tables.Add("secrets", new JArray());

            var mockedRepository = new MockedRepository("IdentityStore");

            mockedRepository.Add("sp_GetAllIdentities", tables["identity"]);
            mockedRepository.Add("sp_AddIdentity", new AddIdentityProcedure(tables));
            mockedRepository.Add("sp_GetIdentity", new GetIdentityProcedure(tables));

            mockedRepository.Add("sp_AddCredential", new AddCredentialProcedure(tables));
            mockedRepository.Add("sp_DeleteIdentityCredentials", new DeleteIdentityCredentialsProcedure(tables));
            mockedRepository.Add("sp_GetUserNameCredential", new GetUserNameCredentialProcedure(tables));

            mockedRepository.Add("sp_AddSharedSecret", new AddSharedSecretProcedure(tables));
            mockedRepository.Add("sp_GetSharedSecret", new GetSharedSecretProcedure(tables));
            mockedRepository.Add("sp_DeleteSharedSecret", new DeleteSharedSecretProcedure(tables));
            mockedRepository.Add("sp_GetIdentitySharedSecrets", new GetIdentitySharedSecretsProcedure(tables));

            mockedRepository.Add("sp_AuthenticateSuccess", new AuthenticateSuccessProcedure(tables));
            mockedRepository.Add("sp_AuthenticateFail", new AuthenticateFailProcedure(tables));

            var mockContextFactory = GetMock <MockContextFactory, IContextFactory>();

            mockContextFactory.MockedRepository = mockedRepository;

            var mockConfiguration = SetupMock <IConfiguration>();
            var passwordHasher    = new PasswordHasher(mockConfiguration);

            _identityStore = new IdentityStoreFacility(
                mockConfiguration,
                SetupMock <IContextFactory>(),
                SetupMock <ICommandFactory>(),
                passwordHasher);
        }