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; }
public void SetUp() { var repo = new MockedRepository(); //log4net repo.SetVersions("log4net", new Version(1, 2, 10, 0), new Version(1, 2, 8, 0), new Version(1, 1, 0, 0)); repo.SetManifest( new PackageKey("log4net", new Version(1, 2, 10, 0), null), new Package("log4net", new Version(1, 2, 10, 0))); repo.SetManifest( new PackageKey("log4net", new Version(1, 2, 8, 0), null), new Package("log4net", new Version(1, 2, 8, 0))); repo.SetManifest( new PackageKey("log4net", new Version(1, 1, 0, 0), null), new Package("log4net", new Version(1, 1, 0, 0))); //Company.Logging repo.SetVersions("Company.Logging", new Version(2, 0, 1, 23), new Version(2, 0, 2, 100), new Version(2, 1, 0, 234), new Version(2, 1, 4, 567), new Version(2, 1, 8, 1987), new Version(3, 0, 0, 4863)); Package loggingManifest30 = new Package("Company.Logging", new Version(3, 0, 0, 4863)); loggingManifest30.Dependencies.Add(new PackageDependency("log4net", "1.2")); repo.SetManifest( new PackageKey("Company.Logging", new Version(3, 0, 0, 4863), null), loggingManifest30); _repo = repo; }
public async Task Should_Get_Entity_When_UpdateEntityAsync() { var mockedContext = new Mock <IDynamoDBContext>(); var mockedRepository = new MockedRepository(mockedContext); var entity = await mockedRepository.UpdateEntityAsync(Guid.NewGuid(), new MockedAssigableEntity(Guid.NewGuid())); Assert.NotNull(entity); }
public async Task Should_Get_Entity_When_SoftDeleteEntityAsync() { var mockedContext = new Mock <IDynamoDBContext>(); var mockedRepository = new MockedRepository(mockedContext); var entity = await mockedRepository.DeleteEntityAsync(Guid.NewGuid(), false); Assert.NotNull(entity); }
public void CreateFactoryAndReturnRepositories() { var repo = new MockedRepository(); var underTest = new MockedSessionFactory(repos: repo.Object); var cmisParameters = new Dictionary<string, string>(); var repos = underTest.Object.GetRepositories(cmisParameters); Assert.That(repos.First(), Is.EqualTo(repo.Object)); }
public void CreateFactoryAndReturnRepositories() { var repo = new MockedRepository(); var underTest = new MockedSessionFactory(repos: repo.Object); var cmisParameters = new Dictionary <string, string>(); var repos = underTest.Object.GetRepositories(cmisParameters); Assert.That(repos.First(), Is.EqualTo(repo.Object)); }
public void CreateFactoryAndCreateSession() { var repo = new MockedRepository(); var underTest = new MockedSessionFactory(repos: repo.Object); var cmisParameters = new Dictionary<string, string>(); cmisParameters[SessionParameter.RepositoryId] = repo.Id; var session = underTest.Object.CreateSession(cmisParameters); Assert.That(session, Is.Not.Null); repo.Verify(r => r.CreateSession(), Times.Once); }
public void CreateRepository([Values(true, false)]bool withGivenId) { string repoId = withGivenId ? Guid.NewGuid().ToString() : null; var name = "my"; var underTest = new MockedRepository(repoId, name).Object; Assert.That(underTest.Name, Is.EqualTo(name)); if (withGivenId) { Assert.That(underTest.Id, Is.EqualTo(repoId)); } else { Assert.That(underTest.Id, Is.Not.Null); } }
public void CreateFactoryAndCreateSession() { var repo = new MockedRepository(); var underTest = new MockedSessionFactory(repos: repo.Object); var cmisParameters = new Dictionary <string, string>(); cmisParameters[SessionParameter.RepositoryId] = repo.Id; var session = underTest.Object.CreateSession(cmisParameters); Assert.That(session, Is.Not.Null); repo.Verify(r => r.CreateSession(), Times.Once); }
public void CreateSession() { var repo = new MockedRepository(); var repoService = new MockedServer.MockedServices.MockedRepositoryService(); repoService.RepositoryInfos.Add(repo.Object); repo.RepositoryService = repoService.Object; var session = repo.Object.CreateSession(); Assert.That(session, Is.Not.Null); Assert.That(session.GetRootFolder(), Is.EqualTo(repo.MockedRootFolder.Object)); var rootFolder = session.GetRootFolder(); rootFolder.DeleteTree(true, null, true); Assert.Throws<CmisObjectNotFoundException>(() => session.GetRootFolder()); Assert.Throws<CmisObjectNotFoundException>(() => rootFolder.DeleteTree(true, null, true)); }
public void CreateSession() { var repo = new MockedRepository(); var repoService = new MockedServer.MockedServices.MockedRepositoryService(); repoService.RepositoryInfos.Add(repo.Object); repo.RepositoryService = repoService.Object; var session = repo.Object.CreateSession(); Assert.That(session, Is.Not.Null); Assert.That(session.GetRootFolder(), Is.EqualTo(repo.MockedRootFolder.Object)); var rootFolder = session.GetRootFolder(); rootFolder.DeleteTree(true, null, true); Assert.Throws <CmisObjectNotFoundException>(() => session.GetRootFolder()); Assert.Throws <CmisObjectNotFoundException>(() => rootFolder.DeleteTree(true, null, true)); }
public void CreateRepository([Values(true, false)] bool withGivenId) { string repoId = withGivenId ? Guid.NewGuid().ToString() : null; var name = "my"; var underTest = new MockedRepository(repoId, name).Object; Assert.That(underTest.Name, Is.EqualTo(name)); if (withGivenId) { Assert.That(underTest.Id, Is.EqualTo(repoId)); } else { Assert.That(underTest.Id, Is.Not.Null); } }
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); }
public void MockedRepository_CreateRepository_Success() { MockedRepository repository = new MockedRepository(); Assert.IsNotNull(repository); }
public ActionResult <IEnumerable <string> > Get() { return(MockedRepository.GetAllProducts().Select(p => p.Name).ToList()); }