public async Task UpdateBrandInfo_Should_Update_Brand_With_Specified_Values() { var brand = Brand.Create("brand to edit", "brand-to-edit"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>())) .Returns(Task.FromResult(brand)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid brandId = brand.Id; string name = "brand"; string url = "url"; string description = "description"; Image logo = new Image { MimeType = "image/jpeg", Data = new byte[0] }; var commands = new BrandCommands(repository, eventBus); await commands.UpdateBrandInfo(brandId, name, url, description, logo); Assert.Equal(name, brand.Name); Assert.Equal(url, brand.Url); Assert.Equal(description, brand.Description); Assert.Equal(logo, brand.Logo); }
public async Task CreateNewCustomAttribute_Should_Create_A_New_Custom_Attribute_And_Return_The_Created_Attribute_Id() { var fakeCustomAttributeList = new List <CustomAttribute>(); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.Add(It.IsAny <CustomAttribute>())) .Callback <CustomAttribute>((attribute) => fakeCustomAttributeList.Add(attribute)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; string name = "Size"; string type = "string"; string description = "size description"; string unitOfMeasure = "unit"; IEnumerable <object> values = new[] { "XS", "S", "M", "L", "XL" }; var commands = new CustomAttributeCommands(repository, eventBus); var attributeId = await commands.CreateNewCustomAttribute(name, type, description, unitOfMeasure, values); var createdAttribute = fakeCustomAttributeList.FirstOrDefault(a => a.Id == attributeId); Assert.Equal(name, createdAttribute.Name); Assert.Equal(type, createdAttribute.DataType); Assert.Equal(description, createdAttribute.Description); Assert.Equal(unitOfMeasure, createdAttribute.UnitOfMeasure); Assert.Equal(values, createdAttribute.Values); }
public async Task RemoveParentForCategory_Should_Remove_The_Category_Parent() { var category = Category.Create("code", "name", "url"); var parent = Category.Create("parent", "parent", "parent"); category.SetParentCategory(parent); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(category.Id)) .Returns(Task.FromResult(category)); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(parent.Id)) .Returns(Task.FromResult(parent)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; Guid parentId = parent.Id; var commands = new CategoryCommands(repository, eventBus); await commands.RemoveParentForCategory(categoryId, parentId); Assert.Null(category.Parent); }
public async Task RemoveChildForCategory_Should_Remove_Child_From_The_Category_Children() { var category = Category.Create("mycode", "Category name", "category-url"); var child = Category.Create("childcode", "Child", "child"); category.AddChild(child); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(category.Id)) .Returns(Task.FromResult(category)); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(child.Id)) .Returns(Task.FromResult(child)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; Guid childId = child.Id; var commands = new CategoryCommands(repository, eventBus); await commands.RemoveChildForCategory(categoryId, childId); Assert.False(category.Children.Contains(child)); }
public BeneficiaryService(UnitOfWork uow) : base(uow) { UserService = new UserService(uow); HIVStatusService = new HIVStatusService(uow); HIVStatusQueryService = new HIVStatusQueryService(uow); SimpleEntityRepository = uow.Repository <SimpleEntity>(); }
public TrimesterService(UnitOfWork unitOfWork, ITrimesterQueryService trimesterQueryService) : base(unitOfWork) { TrimesterDefinitionRepository = unitOfWork.Repository <TrimesterDefinition>(); TrimesterRepository = unitOfWork.Repository <Trimester>(); QueryService = trimesterQueryService; }
public async Task UpdateCategoryInfo_Should_Update_Category_With_Specified_Values() { var category = Category.Create("mycode", "Category name", "category-url"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>())) .Returns(Task.FromResult(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; string code = "code"; string name = "name"; string url = "url"; string description = "description"; bool isVisible = true; DateTime?visibleFrom = DateTime.Today; DateTime?visibleTo = DateTime.Today.AddYears(1); var commands = new CategoryCommands(repository, eventBus); await commands.UpdateCategoryInfo(categoryId, code, name, url, description, isVisible, visibleFrom, visibleTo); Assert.Equal(code, category.Code); Assert.Equal(name, category.Name); Assert.Equal(url, category.Url); Assert.Equal(description, category.Description); Assert.Equal(isVisible, category.IsVisible); Assert.Equal(visibleFrom, category.VisibleFrom); Assert.Equal(visibleTo, category.VisibleTo); }
public async Task CreateNewCategory_Should_Create_A_New_Category_And_Return_The_Created_Category_Id() { var fakeCategoryList = new List <Category>(); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.Add(It.IsAny <Category>())) .Callback <Category>((category) => fakeCategoryList.Add(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; string code = "code"; string name = "name"; string url = "url"; string description = "description"; bool isVisible = true; DateTime?visibleFrom = DateTime.Today; DateTime?visibleTo = DateTime.Today.AddYears(1); var commands = new CategoryCommands(repository, eventBus); var categoryId = await commands.CreateNewCategory(code, name, url, description, isVisible, visibleFrom, visibleTo); var createdCategory = fakeCategoryList.FirstOrDefault(c => c.Id == categoryId); Assert.NotNull(createdCategory); Assert.Equal(code, createdCategory.Code); Assert.Equal(name, createdCategory.Name); Assert.Equal(url, createdCategory.Url); Assert.Equal(description, createdCategory.Description); Assert.Equal(isVisible, createdCategory.IsVisible); Assert.Equal(visibleFrom, createdCategory.VisibleFrom); Assert.Equal(visibleTo, createdCategory.VisibleTo); }
public async Task UpdateCustomAttribute_Should_Update_Custom_Attribute_With_Specified_Values() { var attribute = CustomAttribute.Create("attribute", "number"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <CustomAttribute>(It.IsAny <Guid>())) .Returns(Task.FromResult(attribute)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid attributeId = attribute.Id; string name = "Size"; string type = "string"; string description = "size description"; string unitOfMeasure = "unit"; IEnumerable <object> values = new[] { "XS", "S", "M", "L", "XL" }; var commands = new CustomAttributeCommands(repository, eventBus); await commands.UpdateCustomAttribute(attributeId, name, type, description, unitOfMeasure, values); Assert.Equal(name, attribute.Name); Assert.Equal(type, attribute.DataType); Assert.Equal(description, attribute.Description); Assert.Equal(unitOfMeasure, attribute.UnitOfMeasure); Assert.Equal(values, attribute.Values); }
public async Task CreateNewBrand_Should_Create_A_New_Brand_And_Return_The_Created_Brand_Id() { var fakeBrandList = new List <Brand>(); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.Add(It.IsAny <Brand>())) .Callback <Brand>((brand) => fakeBrandList.Add(brand)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; string name = "brand"; string url = "url"; string description = "description"; Image logo = new Image { MimeType = "image/jpeg", Data = new byte[0] }; var commands = new BrandCommands(repository, eventBus); var brandId = await commands.CreateNewBrand(name, url, description, logo); var createdBrand = fakeBrandList.FirstOrDefault(b => b.Id == brandId); Assert.NotNull(createdBrand); Assert.Equal(name, createdBrand.Name); Assert.Equal(url, createdBrand.Url); Assert.Equal(description, createdBrand.Description); Assert.Equal(logo, createdBrand.Logo); }
public GitHub(Repository.IRepository <Models.GitHub.Settings> settingsRepository, IGitHub <Models.GitHub.Branch> branchService, IGitHub <Models.GitHub.PullRequest> pullRequestService, IGitHub <Models.GitHub.Comment> commentService) { _settingsRepository = settingsRepository; _branchService = branchService; _pullRequestService = pullRequestService; _commentService = commentService; }
public void Ctor_Should_Throw_ArgumentNullException_If_Repository_Is_Null() { Repository.IRepository repository = null; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; var ex = Assert.Throws <ArgumentNullException>(() => new CategoryCommands(repository, eventBus)); Assert.Equal(nameof(repository), ex.ParamName); }
public ActionResult Display() { if (repo == null) { repo = new Repository.realRepository(new Database()); } IEnumerable <entity> e = repo.getAll(Repository.realRepository.type.USER); return(View(modelLST(e))); }
public ActionResult Display(int id) { ViewBag.id = id; if (repo == null) { repo = new Repository.realRepository(new Database()); } /*Database data = new Database(); * List<shipModel> thisUserShips = new List<shipModel>(); * foreach (Data.Entities.spaceship ship in data.ships) { * if (ship.userId == id) thisUserShips.Add(toModel(ship)); * }*/ return(View(toModelLST(repo.getAll(Repository.realRepository.type.SPACESHIP, id)))); }
public async Task DeleteCustomAttribute_Should_Mark_CustomAttribute_As_Deleted() { var attribute = CustomAttribute.Create("attribute", "number"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <CustomAttribute>(It.IsAny <Guid>())) .Returns(Task.FromResult(attribute)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid attributeId = attribute.Id; var commands = new CustomAttributeCommands(repository, eventBus); await commands.DeleteCustomAttribute(attributeId); Assert.True(attribute.Deleted); }
public async Task DeleteCategory_Should_Mark_Category_As_Deleted() { var category = Category.Create("code", "name", "url"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>())) .Returns(Task.FromResult(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; var commands = new CategoryCommands(repository, eventBus); await commands.DeleteCategory(categoryId); Assert.True(category.Deleted); }
public async Task DeleteBrand_Should_Mark_Brand_As_Deleted() { var brand = Brand.Create("brand to edit", "brand-to-edit"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>())) .Returns(Task.FromResult(brand)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid brandId = brand.Id; var commands = new BrandCommands(repository, eventBus); await commands.DeleteBrand(brandId); Assert.True(brand.Deleted); }
public List <UserQuizPublish> GetListOfUsersForPublication(int idquiz, string userId) { using (Repository.IRepository repository = QuizAPI.Repository.Repository.CreateRepository()) { Domain.Quiz quiz = repository.GetQuiz(idquiz); if (quiz.Creator.Id == userId) { List <UserQuizPublish> returnList = new List <UserQuizPublish>(); if (quiz != null) { //List of users that have been marked to answer the quiz List <string> usersMarkedToAnswer = repository.GetUsersIds(quiz); //List of users that have an answer in the database for that quiz List <string> usersThatAnswered = repository.GetUsersIds(quiz, true); List <Domain.UserQuiz> users = repository.GetUsers(); foreach (var item in users) { if (item.Id != userId) { returnList.Add(new UserQuizPublish() { IdQuiz = idquiz, IdUser = item.Id, IsMarked = usersMarkedToAnswer.Any(r => r == item.Id), Username = item.UserName, HasAnswered = usersThatAnswered.Any(r => r == item.Id) }); } } } return(returnList); } } return(null); }
public GASender() { InitializeComponent(); _logger = LogManager.GetLogger(GetType().Name); try { var busConfiguration = ConfigService.Instance.Bus; if (busConfiguration == null) { throw new Exception("BusConfiguration must be set in config"); } var kernel = new StandardKernel(); kernel.Bind <IMessageBodySerializer>().To <DefaultJsonSerializer>().InSingletonScope(); kernel.Bind <IBusLogger>().To <CustomNLogger>().InSingletonScope(); NinjectContainerAdapter.CreateInstance(kernel); BusFactory.SetContainerFactory(NinjectContainerAdapter.GetInstance); _messageBus = BusFactory.CreateBus(); _repository = new Repository.Repository(ConfigService.Instance.Payments.W1ConnectionString); _sendService = new PaymentsService( _repository, ConfigService.Instance.Common.GoogleAnaliticsUrl, ConfigService.Instance.Common.TrackingId, ConfigService.Instance.Payments.Interval, ConfigService.Instance.Common.GoogleAnaliticsTimeout, ConfigService.Instance.Payments.StartTime, ConfigService.Instance); } catch (Exception exception) { _logger.Error(exception); throw; } }
public async Task SetCategorySeoData_Should_Set_The_Seo_Data_With_The_Specified_Values() { var category = Category.Create("code", "name", "url"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Category>(It.IsAny <Guid>())) .Returns(Task.FromResult(category)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid categoryId = category.Id; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new CategoryCommands(repository, eventBus); await commands.SetCategorySeoData(categoryId, seo); Assert.Equal(seo.Title, category.Seo.Title); Assert.Equal(seo.Description, category.Seo.Description); }
public async Task SetBrandSeoData_Should_Set_SeoData_With_Specified_Values() { var brand = Brand.Create("brand to edit", "brand-to-edit"); var repositoryMock = new Mock <Repository.IRepository>(); repositoryMock.Setup(r => r.GetByKeyAsync <Brand>(It.IsAny <Guid>())) .Returns(Task.FromResult(brand)); Repository.IRepository repository = repositoryMock.Object; Core.Infrastructure.IEventBus eventBus = new Mock <Core.Infrastructure.IEventBus>().Object; Guid brandId = brand.Id; SeoData seo = new SeoData { Title = "title", Description = "description" }; var commands = new BrandCommands(repository, eventBus); await commands.SetBrandSeoData(brandId, seo); Assert.NotNull(brand.Seo); Assert.Equal(seo.Title, brand.Seo.Title); Assert.Equal(seo.Description, brand.Seo.Description); }
public Issues(Services.IIssues service, Repository.IRepository<Models.Issues.Query> settingsRepository) { _service = service; _settingsRepository = settingsRepository; }
public OfferController(Repository.IRepository repository, ILogger <OfferController> logger, IMapper mapper) { _repository = repository; _logger = logger; _mapper = mapper; }
public InvoiceService(IRepository <Invoice.Repository.Migrations.Invoice> repository, DynamcisLinkDBContext _context, IInvoiceDetailService invDetailsService) { this.repository = repository; this._context = _context; this.invDetailsService = invDetailsService; }
public MessagesController(Repository.IRepository<Chat.Models.Message> messageRepository) { // TODO: Complete member initialization this.messageRepository = messageRepository as MessageRepository; }
public Environments(Repository.IRepository<Models.Environments.Tenant> repository) { _repository = repository; }
public RedAlert(Repository.IRepository<Models.RedAlert> repository) { _repository = repository; }
public StoreService(IRepository <Stores> repository) { this.repository = repository; }
public ProductService(Repository.IRepository <Models.ServiceProduct, Result.Result <Models.ServiceProduct> > repository, ILogger <UserService> logger) : base(repository) { _Logger = logger; }
public BookingBase() { bookingRep = RepositoryUnitOfWork.Instance.GetRepository<Reservation>(); }
public EmployeeBase() { employeeRep = RepositoryUnitOfWork.Instance.GetRepository<Employee>(); }
public Screens(Repository.IRepository<Models.Screens.Screen> repository) { _repository = repository; }
public Deployments(Services.IDeployments service, Repository.IRepository<Models.Deployments.Environment> settingsRepository) { _service = service; _settingsRepository = settingsRepository; }
public MessagesController(Repository.IRepository <Chat.Models.Message> messageRepository) { // TODO: Complete member initialization this.messageRepository = messageRepository as MessageRepository; }
public Builds(Services.IBuilds service, Repository.IRepository<Build> settingsRepository) { _service = service; _settingsRepository = settingsRepository; }
/// <summary> /// Construct the customer commands /// </summary> /// <param name="repository">The repository instance</param> /// <param name="authClient">The auth client instance</param> /// <param name="eventBus">The event bus instance</param> public CustomerCommands(Repository.IRepository repository, IAuthClient authClient, IEventBus eventBus) { Repository = repository ?? throw new ArgumentNullException(nameof(repository)); AuthClient = authClient ?? throw new ArgumentNullException(nameof(authClient)); EventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); }
public ListingController() { String dbPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/") + "cc.db"; this.ListingRepository = new Repository.LightDB(dbPath); }
public UserService(Repository.IRepository <Models.User, Result.Result <Models.User> > repository, ILogger <UserService> logger) : base(repository) { _Logger = logger; }
public RedAlert(Repository.IRepository <Models.RedAlert> repository) { _repository = repository; }