public RegisterValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.FirstName)
            .NotEmpty()
            .MaximumLength(30);

            RuleFor(x => x.LastName)
            .NotEmpty()
            .MaximumLength(30);

            RuleFor(x => x.Email)
            .NotEmpty()
            .EmailAddress();

            RuleFor(x => x.Password)
            .NotEmpty()
            .MinimumLength(8)
            .MaximumLength(20);

            RuleFor(x => x.Email)
            .Must(x => !IsEmailAlreadyTaken(x))
            .WithMessage("Email {PropertyValue} is already taken");
        }
        public void Initialize(BugTrackerContext context)
        {
            if (!context.ProjectItems.Any())
            {
                context.Add(new ProjectItem {
                    Name = "Task 1", Description = "Task 1", Created = DateTime.UtcNow.AddDays(1), Modified = DateTime.UtcNow.AddDays(1)
                });
                context.Add(new ProjectItem {
                    Name = "Task 2", Description = "Task 2", Created = DateTime.UtcNow.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1)
                });
                context.Add(new ProjectItem {
                    Name = "Task 3", Description = "Task 3", Created = DateTime.UtcNow.AddDays(2), Modified = DateTime.UtcNow.AddDays(2)
                });
            }

            if (!context.TaskItems.Any())
            {
                context.Add(new TaskItem {
                    Name = "Task 1", Description = "Task 1", Priority = TaskItem.TaskPriority.High, Created = DateTime.Now.AddDays(1), Modified = DateTime.UtcNow.AddDays(1)
                });
                context.Add(new TaskItem {
                    Name = "Task 2", Description = "Task 2", Priority = TaskItem.TaskPriority.Low, Created = DateTime.Now.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1)
                });
                context.Add(new TaskItem {
                    Name = "Task 3", Description = "Task 3", Priority = TaskItem.TaskPriority.Medium, Created = DateTime.Now.AddDays(2), Modified = DateTime.UtcNow.AddDays(2)
                });
            }

            context.SaveChanges();
        }
        public AddRoleCaseValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.RoleId)
            .NotNull()
            .DependentRules(() =>
            {
                RuleFor(x => x.RoleId)
                .Must(x => RoleExists((int)x))
                .WithMessage("ApplicationUser with id = '{PropertyValue}' doesn't exist.")
                .DependentRules(() =>
                {
                    RuleFor(x => x.UseCaseId)
                    .NotNull()
                    .DependentRules(() =>
                    {
                        RuleFor(x => x.UseCaseId)
                        .NotNull()
                        .Must((dto, caseId) => !RoleCaseExists((int)dto.RoleId, (int)dto.UseCaseId))
                        .WithMessage("Entity already exists.");
                    });
                });
            });
        }
        public AddApplicationUserValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.FirstName)
            .NotEmpty()
            .MaximumLength(30);

            RuleFor(x => x.LastName)
            .NotEmpty()
            .MaximumLength(30);

            RuleFor(x => x.Email)
            .NotEmpty()
            .EmailAddress();

            RuleFor(x => x.Password)
            .MinimumLength(8)
            .MaximumLength(20);

            RuleFor(x => x.Email)
            .Must(x => !IsEmailAlreadyTaken(x))
            .WithMessage("Email {PropertyValue} is already taken");

            RuleFor(x => x.RoleId)
            .Must(x => RoleExists(x))
            .WithMessage("Role with id = '{PropertyValue}' doesn't exist");
        }
Esempio n. 5
0
        public void ProductAddedUnhandledExceptionInPlugIn()
        {
            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerManager manager = new BugTrackerManager(folders);

            Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);

            StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();

            plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
            plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
            plugInSettings.PlugInSettings[0].Enabled = true;

            BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

            StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");

            Assert.AreEqual(1, fullDiagnostics.Count);
            NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);


            NameValueCollection properties = new NameValueCollection();

            properties.Add("UnhandledException", "1");

            plugInContext.SetProperties("TestPlugIn", properties);

            plugInContext.ProductAdded(null, BugTrackerReportType.Automatic, null);

            fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
            Assert.AreEqual(1, fullDiagnostics.Count);
            diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);
        }
Esempio n. 6
0
 public TicketsController(BugTrackerContext context,
                          UserManager <ApplicationUser> userManager,
                          AuthDbContext dbContext)
 {
     _context     = context;
     _userManager = userManager;
     _dbContext   = dbContext;
 }
Esempio n. 7
0
 public ProjectsController(BugTrackerContext context,
                           SignInManager <ApplicationUser> signInManager,
                           UserManager <ApplicationUser> userManager)
 {
     this.signInManager = signInManager;
     this.context       = context;
     this.userManager   = userManager;
 }
Esempio n. 8
0
        public AddRoleValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .MaximumLength(30)
            .Must(x => !RoleExists(x))
            .WithMessage("Role with name = '{PropertyValue}' already exists");
        }
Esempio n. 9
0
 public ProjectsController(BugTrackerContext context,
                           IAuthorizationService authorizationService,
                           UserManager <ApplicationUser> userManager,
                           AuthDbContext dbContext,
                           ClaimsPrincipal claimsPrincipal)
 {
     _context = context;
     _authorizationService = authorizationService;
     _userManager          = userManager;
     _dbContext            = dbContext;
     _claimsPrincipal      = claimsPrincipal;
 }
Esempio n. 10
0
        public RemoveRoleCaseValidator(BugTrackerContext context
                                       , UseCaseExecutor useCaseExector
                                       , IGetOneRoleCaseQuery query)
        {
            _context        = context;
            _useCaseExector = useCaseExector;
            _query          = query;

            RuleFor(x => x.RoleId)
            .Must((dto, userId) => ApplicationUserCaseExists(dto))
            .WithMessage("Entity with given ApplicationUserId and CaseId doesn't exist");
        }
Esempio n. 11
0
 static void Main(string[] args)
 {
     using (var c = new BugTrackerContext())
     {
         c.Database.Delete();
         c.Database.Create();
     }
     using (var c = new BugTrackerContext())
     {
         var user = c.Users.Create();
         user.Login     = "******";
         user.FirstName = "Giovanni";
         user.LastName  = "Solinas";
         user.Password  = "******";
         user.BirthDate = new DateTime(1998, 9, 11);
         user.Address   = new Address()
         {
             ZipCode = 16100
         };
         c.Users.Add(user);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product = c.Products.Create();
         product.Code           = 42;
         product.CommercialName = "Motore";
         product.InternalName   = "Motore 1.5 95 cv";
         product.Description    = "abajdcowjdbcjdbcwjbcw";
         c.Products.Add(product);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product = c.Products.Create();
         product.Code           = 27;
         product.CommercialName = "Matita";
         product.InternalName   = "Matita bianca";
         product.Description    = "oojosjcbdwjcoswcojbwe";
         c.Products.Add(product);
         c.SaveChanges();
     }
     using (var c = new BugTrackerContext())
     {
         var product1 = c.Products.FirstOrDefault(p => p.Code == 1);
         var product2 = c.Products.FirstOrDefault(p => p.Code == 2);
         product1.DependsOn.Add(product2);
         c.SaveChanges();
     }
 }
        public AddProjectValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Name)
            .NotEmpty()
            .MaximumLength(30)
            .Must(x => !IsNameAlreadyTaken(x))
            .WithMessage("Project with name = '{PropertyValue}' already exists");

            RuleFor(x => x.Description)
            .NotEmpty()
            .MaximumLength(150);
        }
        public AddAttachmentValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.TicketId)
            .Must(x => TicketExists(x))
            .WithMessage("Ticket with id = '{PropertyValue}' doesn't exist'.");

            RuleFor(x => x.Name)
            .Must(x => !IsNameAlreadyTaken(x))
            .WithMessage("Attachment with name = '{PropertyValue}' already exists");

            RuleFor(x => x.File)
            .NotNull();
        }
        public ChangeCommentValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Text)
            .MaximumLength(300);

            RuleFor(x => x.ApplicationUserId)
            .Must(x => UserExists(x))
            .WithMessage("User with id = {PropertyValue} doesn't exist.");

            RuleFor(x => x.TicketId)
            .Must(x => TicketExist(x))
            .WithMessage("Ticket with id = {PropertyValue} doesn't exist.");
        }
Esempio n. 15
0
        public LoginValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Email)
            .NotEmpty()
            .Must(x => UserExists(x))
            .WithMessage("User with email = {PropertyValue} doesn't exist.")
            .DependentRules(() =>
            {
                RuleFor(x => x.Password)
                .NotEmpty()
                .Must((dto, x) => CheckPassword(dto))
                .WithMessage("Password is invalid.");
            });
        }
        public ChangeAttachmentValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .Must(x => AttachmentExists(x))
            .WithMessage("Attachment with id = '{PropertyValue}' doesn't exist'.");

            RuleFor(x => x.Name)
            .Must((dto, x) => !IsNameAlreadyTaken(dto))
            .WithMessage("Attachment with name = '{PropertyValue}' already exists");

            RuleFor(x => x.TicketId)
            .Must(x => TicketExists(x))
            .WithMessage("Ticket with id = '{PropertyValue}' doesn't exist'.");
        }
Esempio n. 17
0
        public AddProjectApplicationUserValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.ProjectId)
            .NotEmpty()
            .Must(x => ProjectExists(x))
            .WithMessage("Project with id = '{PropertyValue}' doesn't exist.");

            RuleFor(x => x.ApplicationUserId)
            .NotEmpty()
            .Must(x => ApplicationUserExists(x))
            .WithMessage("ApplicationUser with id = '{PropertyValue}' doesn't exist.");

            RuleFor(x => x.ProjectId)
            .Must((dto, projectId) => !ProjectApplicationUserAlreadyExist(dto.ProjectId, dto.ApplicationUserId))
            .WithMessage("Entity with given projectId and applicationUserId already exist.");
        }
Esempio n. 18
0
        public UserController(BugTrackerContext context)
        {
            _context = context;

            if (_context.Users.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Users.Add(new User {
                    Id = 1, Name = "James Radley"
                });
                _context.Users.Add(new User {
                    Id = 2, Name = "Jane Doe"
                });
                _context.Users.Add(new User {
                    Id = 3, Name = "Joe Bloggs"
                });
                _context.SaveChanges();
            }
        }
        public ChangeTicketValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.Id)
            .Must(x => TicketExists(x))
            .WithMessage("Ticket with id = '{PropertyValue}' doesn't exists");

            RuleFor(x => x.OriginalTicketId)
            .Must(x => TicketExists(x))
            .WithMessage("Ticket with id = '{PropertyValue}' doesn't exists");

            RuleFor(x => (int)x.Priority)
            .InclusiveBetween(0, 3);

            RuleFor(x => (int)x.Status)
            .InclusiveBetween(0, 4);

            RuleFor(x => (int)x.Type)
            .InclusiveBetween(0, 1);

            RuleFor(x => x.IssuerId)
            .Must(x => ApplicationUserExists(x))
            .WithMessage("ApplicationUser with id = '{PropertyValue}' doesn't exists");

            RuleFor(x => x.DeveloperId)
            .Must(x => ApplicationUserExists(x))
            .WithMessage("ApplicationUser with id = '{PropertyValue}' doesn't exists");

            RuleFor(x => x.Title)
            .NotEmpty()
            .MaximumLength(30);

            RuleFor(x => x.Description)
            .NotEmpty()
            .MaximumLength(150);

            RuleFor(x => x.ProjectId)
            .Must(x => ProjectExists(x))
            .WithMessage("Project with id = '{PropertyValue}' doesn't exists");
        }
Esempio n. 20
0
        public void GetContextSettings()
        {
            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerManager manager = new BugTrackerManager(folders);

            StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();

            plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
            plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
            plugInSettings.PlugInSettings[0].Enabled = true;

            BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

            Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);

            StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");

            Assert.AreEqual(1, fullDiagnostics.Count);

            Assert.AreEqual("http://www.stackhash.com/", fullDiagnostics[0].HelpUrl.ToString());
            Assert.AreEqual(true, fullDiagnostics[0].Loaded);
            Assert.AreEqual("Plug-in used to control StackHash unit testing.", fullDiagnostics[0].PlugInDescription);
            Assert.AreEqual(true, fullDiagnostics[0].PlugInSetsBugReference);

            NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);
        }
        public ChangeProfileValidator(BugTrackerContext context)
        {
            _context = context;

            RuleFor(x => x.FirstName)
            .MaximumLength(30);

            RuleFor(x => x.LastName)
            .MaximumLength(30);

            RuleFor(x => x.Email)
            .EmailAddress();

            RuleFor(x => x.Password)
            .MinimumLength(8)
            .MaximumLength(20);

            RuleFor(x => x.Email)
            .Must((dto, x) => !IsEmailAlreadyTaken(dto))
            .WithMessage("Email {PropertyValue} is already taken");
        }
Esempio n. 22
0
        public BugController(BugTrackerContext context)
        {
            _context = context;

            _context.Bugs.Include(b => b.AssignedToUser);

            if (_context.Bugs.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Users.Add(new User {
                    Id = 1, Name = "James Radley"
                });
                _context.Users.Add(new User {
                    Id = 2, Name = "Jane Doe"
                });
                _context.Users.Add(new User {
                    Id = 3, Name = "Joe Bloggs"
                });
                _context.SaveChanges();
            }

            if (_context.Bugs.Count() == 0)
            {
                // Create test data here. TODO: Wire up to db later.
                _context.Bugs.Add(new Bug {
                    Id = 1, Title = "A bug", Description = "This is a bug", DateOpened = new DateTime(2018, 03, 01), IsActive = true, AssignedToUserId = 1
                });
                _context.Bugs.Add(new Bug {
                    Id = 2, Title = "Another bug", Description = "Here is another bug", DateOpened = new DateTime(2018, 05, 14), IsActive = true, AssignedToUserId = 1
                });
                _context.Bugs.Add(new Bug {
                    Id = 3, Title = "Yet Another bug", Description = "Here is yet another bug", DateOpened = new DateTime(2018, 06, 01), IsActive = true, AssignedToUserId = 2
                });
                _context.Bugs.Add(new Bug {
                    Id = 4, Title = "And Finally Another bug", Description = "Here is finally another bug", DateOpened = new DateTime(2018, 08, 17), IsActive = true, AssignedToUserId = 3
                });
                _context.SaveChanges();
            }
        }
 public EfRemoveApplicationUserCaseCommand(BugTrackerContext context) : base(context)
 {
 }
 public EfGetOneApplicationUserQuery(BugTrackerContext context, IMapper mapper) : base(context)
 {
     _mapper = mapper;
 }
Esempio n. 25
0
 public EfChangeProfileCommand(BugTrackerContext context, IApplicationActor actor) : base(context)
 {
     _actor = actor;
 }
Esempio n. 26
0
 public EfAddTicketCommand(BugTrackerContext context) : base(context)
 {
 }
 public SeverityController(BugTrackerContext context)
 {
     _context = context;
 }
 public CommentsController(BugTrackerContext context)
 {
     _context = context;
 }
 public EfGetOneApplicationUserCaseQuery(BugTrackerContext context) : base(context)
 {
 }
 public EfChangeCommentCommand(BugTrackerContext context
                               , IMapper mapper
                               ) : base(context)
 {
     _mapper = mapper;
 }