SearchSchema_when_schema_is_not_online_returns_stream_with_the_data_is_not_available() { //arrange var dsObj2 = new DataSetSchema() { Title = "schemaurl-disabled-true", IsDisabled = true, IsApproved = true, Category = new Category() { IsDisabled = false } }; _repositoryDataSetSchema.Add(dsObj2); var mut = new DataShareService(); //act var stream = mut.SearchSchemaTextContains("", "schemaurl-disabled-true", "xml", "searchField", "searchtext"); var sr = new StreamReader(stream); var myStr = sr.ReadToEnd(); var result = myStr.Contains("This data is not available"); //assert Assert.IsTrue(result); //cleanup _repositoryDataSetSchema.Delete(dsObj2); }
public static MemoryRepository<Recipe> GetRecipeRepositiry(int numberOfRecipes) { var repo = new MemoryRepository<Recipe>(); repo.Add(new Recipe() { Id = 1, Title = "Tandoori Carrots", Preparation = "Preparation 1, Preparation 1, Preparation 1, Preparation 1, Preparation 1, Preparation 1, Preparation 1, Preparation 1, Preparation 1", Category = new Category() { Name = "Healthy" }, CreatedOn = new DateTime(2016, 1, 12, 12, 12, 12), Creator = new User() { NickName = "Creator 1" }, Tags = new List<Tag>() { new Tag() { Text = "default" } }, Images = new List<RecipeImage>() { new RecipeImage() { OriginalName = "image1.png", Extension = ".png" } } }); repo.Add(new Recipe() { Id = 2, Title = "Sheetpandinners Chicken", Preparation = "Preparation 2, Preparation 2, Preparation 2, Preparation 2, Preparation 2, Preparation 2, Preparation 2, Preparation 2, Preparation 2", Category = new Category() { Name = "Quick and Easy" }, CreatedOn = new DateTime(2016, 1, 12, 11, 11, 11), Creator = new User() { NickName = "Creator 2" }, Tags = new List<Tag>() { new Tag() { Text = "default" } }, Images = new List<RecipeImage>() { new RecipeImage() { OriginalName = "image2.png", Extension = ".png" } } }); repo.Add(new Recipe() { Id = 3, Title = "Salad with butter and basted mushrooms", Preparation = "Preparation 3, Preparation 3, Preparation 3, Preparation 3, Preparation 3, Preparation 3, Preparation 3, Preparation 3, Preparation 3", Category = new Category() { Name = "Vegetarian" }, CreatedOn = new DateTime(2016, 1, 12, 10, 10, 10), Creator = new User() { NickName = "Creator 3" }, Tags = new List<Tag>() { new Tag() { Text = "default" } }, Images = new List<RecipeImage>() { new RecipeImage() { OriginalName = "image3.png", Extension = ".png" } } }); for (int i = 4; i <= numberOfRecipes + 3; i++) { var date = DateTime.Now; date.AddDays(i); repo.Add(new Recipe() { Id = i, Title = "Salad with butter and basted mushrooms " + i, Preparation = "Preparation " + i, Category = new Category() { Name = "Vegetarian" }, CreatedOn = date, Tags = new List<Tag>() { new Tag() { Text = "default" } }, Creator = new User() { NickName = "Creator " + i }, Images = new List<RecipeImage>() { new RecipeImage() { OriginalName = "image" + i + ".png", Extension = ".png" } } }); } return repo; }
public void GetAllGroups_will_return_groups_sorted_by_title() { //arrange var group1 = new Group() { Title = "zTitle" }; var group2 = new Group() { Title = "xTitle" }; _repositoryGroup.Add(group1); _repositoryGroup.Add(group2); var mut = new UserAdminService(_provider); //act var result = mut.GetAllGroups(); //assert Assert.AreEqual("xTitle", result[0].Title); //cleanup _repositoryGroup.Delete(group1); _repositoryGroup.Delete(group2); }
public StubDataCustomerRepository(MemoryRepository <Customer> memRepository) { this._memRepository = memRepository; _memRepository.Add(Customer.Create(1, "William Han")); _memRepository.Add(Customer.Create(2, "Martin Fowler")); _memRepository.Add(Customer.Create(3, "Uncle Bob")); }
public static void AddEarningsRepository(this IServiceCollection services) { var today = DateTime.Today; var lastMonth = DateTime.Today.AddMonths(-1); var previousMonth = DateTime.Today.AddMonths(-2); var earningRepository = new MemoryRepository <Earning>(); earningRepository.Add(new Earning { Date = new DateTime(previousMonth.Year, previousMonth.Month, 25), Amount = 2480, Category = EarningCategory.Salary, Subject = "Monthly Salary" }); earningRepository.Add(new Earning { Date = new DateTime(previousMonth.Year, previousMonth.Month, 12), Amount = 440, Category = EarningCategory.Freelancing, Subject = "Freelancing Client A" }); earningRepository.Add(new Earning { Date = new DateTime(lastMonth.Year, lastMonth.Month, 25), Amount = 2480, Category = EarningCategory.Salary, Subject = "Monthly Salary" }); earningRepository.Add(new Earning { Date = new DateTime(lastMonth.Year, lastMonth.Month, 12), Amount = 790, Category = EarningCategory.Freelancing, Subject = "Freelancing Client A" }); earningRepository.Add(new Earning { Date = new DateTime(lastMonth.Year, lastMonth.Month, 4), Amount = 387, Category = EarningCategory.CapitalGain, Subject = "ETF Dividends" }); earningRepository.Add(new Earning { Date = new DateTime(today.Year, today.Month, 25), Amount = 2480, Category = EarningCategory.Salary, Subject = "Monthly Salary" }); earningRepository.Add(new Earning { Date = new DateTime(today.Year, today.Month, 14), Amount = 680, Category = EarningCategory.Freelancing, Subject = "Freelancing Client A" }); earningRepository.Add(new Earning { Date = new DateTime(today.Year, today.Month, 12), Amount = 245, Category = EarningCategory.Flipping, Subject = "Old TV" }); services.AddSingleton <IRepository <Earning> >(earningRepository); }
public void should_add_items_to_repo( Inventory i, Inventory i1, [Frozen] ICommand c) { memoryRepository.Add(i); memoryRepository.Add(i1); var values = memoryRepository.GetAll(); values.ShouldAllBeEquivalentTo(new List <Inventory> { i, i1 }); }
public static MemoryRepository<Comment> GetCommentsRepository() { var commentsRepository = new MemoryRepository<Comment>(); var users = GetUsersRepository(); var posts = GetPostsRepository(); for (int i = 0; i < 20; i++) { var user = users.GetById("id" + i % 10); var post = posts.GetById(i); var comment = new Comment { Id = i, CommentDate = new DateTime(2015, 11, i + 1), Content = "content" + i, PostId = post.Id, Post = post, UserId = user.Id, User = user, }; commentsRepository.Add(comment); } return commentsRepository; }
private MemoryDataContext CreateMockdataContext() { var docs = new MemoryRepository <Document>(); var repos = new MemoryRepository <Repository>(); var orgs = new MemoryRepository <Organization>(); var users = new MemoryRepository <User>(); var newOrg = new Organization() { Created = DateTime.UtcNow, Updated = DateTime.UtcNow, Name = "Test Org", }; orgs.Add(newOrg); var repoData = new MemoryMetadata() { HasPassword = true, Password = "******", RootDirectory = @"C:\Users\alija\Documents\Programming\Test%20Project" }; var newRepo = new Repository() { Name = "Test Repo", OrganizationId = newOrg.Id, SCM = SupportedSystems.Memory, CustomRepositoryInformation = JsonConvert.SerializeObject(repoData) }; repos.Add(newRepo); return(new MemoryDataContext(docs, orgs, repos, users)); }
public static MemoryRepository<Post> GetPostsRepository() { var postsRepository = new MemoryRepository<Post>(); var users = GetUsersRepository(); var threads = GetThreadsRepository(); for (int i = 0; i < 20; i++) { var thread = threads.GetById(i % 5); var user = users.GetById("id" + i % 10); var post = new Post { Content = "content" + i, Id = i, PostDate = new DateTime(2015, 11, i + 1), ThreadId = thread.Id, Thread = thread, UserId = user.Id, User = user }; postsRepository.Add(post); } return postsRepository; }
public static void AddExpensesRepository(this IServiceCollection services) { var today = DateTime.Today; var lastMonth = DateTime.Today.AddMonths(-1); var previousMonth = DateTime.Today.AddMonths(-2); var expensesRepository = new MemoryRepository <Expense>(); expensesRepository.Add(new Expense { Date = new DateTime(previousMonth.Year, previousMonth.Month, 8), Amount = 1050, Category = ExpenseCategory.Housing, Subject = "Rent" }); expensesRepository.Add(new Expense { Date = new DateTime(previousMonth.Year, previousMonth.Month, 18), Amount = 140, Category = ExpenseCategory.Education, Subject = "Books" }); expensesRepository.Add(new Expense { Date = new DateTime(lastMonth.Year, lastMonth.Month, 6), Amount = 1050, Category = ExpenseCategory.Housing, Subject = "Rent" }); expensesRepository.Add(new Expense { Date = new DateTime(lastMonth.Year, lastMonth.Month, 15), Amount = 415, Category = ExpenseCategory.Healthcare, Subject = "H-Care" }); expensesRepository.Add(new Expense { Date = new DateTime(lastMonth.Year, lastMonth.Month, 27), Amount = 76, Category = ExpenseCategory.Entertainment, Subject = "Harry Potter Series" }); expensesRepository.Add(new Expense { Date = new DateTime(today.Year, today.Month, 7), Amount = 1050, Category = ExpenseCategory.Housing, Subject = "Rent" }); expensesRepository.Add(new Expense { Date = new DateTime(today.Year, today.Month, 13), Amount = 870, Category = ExpenseCategory.Entertainment, Subject = "New TV" }); services.AddSingleton <IRepository <Expense> >(expensesRepository); }
public async Task Create_NewOrder_SaveNewOrder() { Mock <Order> mockOrder = new Mock <Order>(); mockOrder.SetupGet(x => x.Id).Returns(OrderId); mockOrder.SetupGet(x => x.CustomerId).Returns(CustomerId); await _orderRepo.Add(mockOrder.Object); var actualOrder = await _orderRepo.FindById(mockOrder.Object.Id); Assert.IsNotNull(actualOrder); }
public void GetAll_returns_all_contacts_in_repository_in_date_created_desc_order() { //arrange var ent1 = new Contact() { DateCreated = new DateTime(2009, 1, 1) }; var ent2 = new Contact() { DateCreated = new DateTime(2010, 1, 1) }; _repository.Add(ent1); _repository.Add(ent2); var sut = new ContactService(_repository, _systemConfigurationService, _emailService); //act var result = sut.GetAll(); //assert Assert.AreEqual(new DateTime(2010, 1, 1), result[0].DateCreated); //cleanup _repository.Delete(ent1); _repository.Delete(ent2); }
public static MemoryRepository<Category> GetCategoriesRepository() { var categoriesRepository = new MemoryRepository<Category>(); for (int i = 0; i < 10; i++) { var category = new Category { Id = i, Name = "category" + i }; categoriesRepository.Add(category); } return categoriesRepository; }
static void Main(string[] args) { var docs = new MemoryRepository <Document>(); var repos = new MemoryRepository <Repository>(); var orgs = new MemoryRepository <Organization>(); var users = new MemoryRepository <User>(); var newOrg = new Organization() { Created = DateTime.UtcNow, Updated = DateTime.UtcNow, Name = "evuru", }; orgs.Add(newOrg); var metadata = new AzureDevOpsMetadata { PersonalAccessToken = "", }; var newRepo = new Repository() { Name = newOrg.Name, OrganizationId = newOrg.Id, SCM = SupportedSystems.GitHub, CustomRepositoryInformation = JsonConvert.SerializeObject(metadata) }; repos.Add(newRepo); var db = new MemoryDataContext(docs, orgs, repos, users); var queue = new MemoryQueue <RepositoryUpdatedMessage>(); while (true) { queue.PushMessage(new RepositoryUpdatedMessage(newRepo.Id)); var scraper = new Scraper(db); scraper.ScrapeRepository(queue.PopMessage()).Wait(); Display(db); Thread.Sleep(30000); } }
static Command GetRunCommand(string key, string description, params IStatement[] statements) { IStatement statement = MakeCompoundStatement(statements); MyIStack <IStatement> executionStack = new MyStack <IStatement>(); executionStack.Push(statement); MyIDictionary <string, int> symbolTable = new MyDictionary <string, int>(); MyIList <int> output = new MyList <int>(); ProgramState programState = new ProgramState(executionStack, symbolTable, output); IRepository repository = new MemoryRepository("log.txt"); repository.Add(programState); InterpreterController controller = new InterpreterController(repository); return(new RunExampleCommand(key, description, controller)); }
public void Delete_when_id_not_found_in_repository_and_definition_is_null() { //arrange var dsd = new DataSetSchemaDefinition() { Id = 2 }; _repository.Add(dsd); var beforeDelete = _repository.GetAll().Count(); var mut = new DataSetSchemaDefinitionService(_repository); //act mut.Delete(1); var result = _repository.GetAll().Count(); //assert Assert.AreEqual(beforeDelete, result); //cleanup _repository.Delete(dsd); }
public void ClearTest() { MemoryRepository mr = MemoryRepository.Instance; Human testHuman = new Human { FirstName = "John", LastName = "Doe", FavoriteColor = Colors.Silver, DateOfBirth = new DateTime(1995, 8, 22), Gender = Genders.Male }; mr.Add(testHuman); mr.Clear(); var result = mr.GetList(); if (result.Count > 0) { Assert.Fail(); } }
public static MemoryRepository<Thread> GetThreadsRepository() { var threadsRepository = new MemoryRepository<Thread>(); var users = GetUsersRepository(); for (int i = 0; i < 5; i++) { var user = users.GetById("id" + i % 10); var thread = new Thread { Id = i, Content = "content" + i, DateCreated = new DateTime(2015, 11, i + 1), Title = "title" + i, UserId = user.Id, User = user }; threadsRepository.Add(thread); } return threadsRepository; }
public void Add_EntityWithIntId_AddedWithNewId() { var target = new MemoryRepository<EntityWithIntIdStub>((e) => 1); target.SetUnitOfWork(m_unitOfWork); target.Add(new EntityWithIntIdStub()); m_unitOfWork.Commit(); var actual = target.FindAll(f => true).ToList(); Assert.AreEqual(1, actual.Count); Assert.AreEqual(1, actual[0].Id); }
public static MemoryRepository<RecipeVote> GetVotesRepositiry(int numberOfVotes) { var repo = new MemoryRepository<RecipeVote>(); var recipe = new Recipe() { Id = 2, Title = "Title " + 2, Preparation = "Preparation " + 2, Ingredients = new List<Ingredient>() { new Ingredient() { Text = "2 cups sugar" } }, CreatedOn = DateTime.Now, Creator = new User() { NickName = "User " + 1 } }; Random rand = new Random(); for (int i = 0; i < numberOfVotes; i++) { var date = DateTime.Now; date.AddDays(i); var vote = new RecipeVote() { Id = i + 1, Recipe = recipe, CreatedOn = date, RecipeId = 2, Type = VoteType.Positive }; repo.Add(vote); } return repo; }
public static MemoryRepository<User> GetUsersRepository() { var usersRepository = new MemoryRepository<User>(); for (int i = 0; i < 10; i++) { var user = new User { Nickname = "Nick " + i, Id = "id" + i, UserName = "******" + i }; usersRepository.Add(user); } return usersRepository; }
public static MemoryRepository<RecipeImage> GetRecipeImagesRepositiry(int numberOfImages) { var repo = new MemoryRepository<RecipeImage>(); for (int i = 1; i <= numberOfImages; i++) { var date = DateTime.Now; date.AddDays(i); byte[] bytes = new byte[20]; new Random().NextBytes(bytes); repo.Add(new RecipeImage() { Id = i, OriginalName = "OriginalName.png", Extension = ".png", Content = bytes, CreatedOn = date, }); } return repo; }
public static MemoryRepository<Article> GetArticlesRepositiry(int numberOfArticles) { var repo = new MemoryRepository<Article>(); for (int i = 0; i < numberOfArticles; i++) { var date = DateTime.Now; date.AddDays(i); var article = new Article() { Id = i, Title = "Title " + i, Content = "Content " + i, CreatedOn = date, Author = new User() { NickName = "User " + i } }; for (int j = 0; j < 10; j++) { article.Comments.Add(new Comment() { Content = "Comment content " + j, CreatedOn = DateTime.Now }); } repo.Add(article); } return repo; }
public void Add(Customer entity) { _memRepository.Add(entity); }