public void A110_Validation_Empty() { ValidationTester.Test() .ExpectMessages( "First Name is required.", "Last Name is required.", "Gender is required.", "Birthday is required.") .Run(() => PersonValidator.Default.Validate(new Person())); }
public void A110_Validate_Initial() { ValidationTester.Test() .ExpectMessages( "Employee is required.", "Date is required.", "Outcome is required.", "Reviewer is required.") .Run(() => PerformanceReviewValidator.Default.Validate(new PerformanceReview())); }
public void B110_CanDelete_NotFound() { var eds = new Mock <IEmployeeDataSvc>(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync((Employee)null !); ValidationTester.Test() .AddScopedService(eds) .ExpectErrorType(Beef.ErrorType.NotFoundError) .Run(() => EmployeeValidator.CanDelete.Validate(1.ToGuid())); }
public async Task A110_Validate_Initial() { await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "Employee is required.", "Date is required.", "Outcome is required.", "Reviewer is required.") .CreateAndRunAsync <IValidator <PerformanceReview>, PerformanceReview>(new PerformanceReview()); }
public async Task A110_Validation_Empty() { await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "First Name is required.", "Last Name is required.", "Gender is required.", "Birthday is required.") .CreateAndRunAsync <IValidator <Person>, Person>(new Person()); }
public async Task A110_ArgsValidator_Empty() { var ta = new TransactionArgs(); var r = await ValidationTester.Test().RunAsync(async() => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r !.HasErrors); Assert.AreEqual(DateTime.UtcNow.Date.AddDays(-90), ta.FromDate !.Value.Date); Assert.IsNull(ta.ToDate); Assert.IsNull(ta.MinAmount); Assert.IsNull(ta.MaxAmount); Assert.IsNull(ta.Text); }
public async Task B110_CanDelete_NotFound() { var eds = new Mock <IEmployeeDataSvc>(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync((Employee)null !); await ValidationTester.Test() .ConfigureServices(_testSetup !) .AddScopedService(eds) .ExpectErrorType(Beef.ErrorType.NotFoundError) .RunAsync(async() => await EmployeeValidator.CanDelete.ValidateAsync(1.ToGuid())); }
public void B110_CanDelete_Invalid() { var eds = new Mock <IEmployeeDataSvc>(); eds.Setup(x => x.GetAsync(1.ToGuid())).ReturnsAsync(new Employee { StartDate = DateTime.UtcNow.AddDays(-1) }); ValidationTester.Test() .AddScopedService(eds) .ExpectErrorType(Beef.ErrorType.ValidationError, "An employee cannot be deleted after they have started their employment.") .Run(() => EmployeeValidator.CanDelete.Validate(1.ToGuid())); }
public void A110_Validate_Initial() { ValidationTester.Test() .ExpectMessages( "First Name is required.", "Email is required.", "Last Name is required.", "Gender is required.", "Birthday is required.", "Start Date is required.", "Phone No is required.") .Run(() => EmployeeValidator.Default.Validate(new Employee())); }
public async Task A140_ArgsValidator_ValidDiff() { var ta = new TransactionArgs { FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2020, 04, 01), MinAmount = 100m, MaxAmount = 120m, Text = "Best Buy" }; var r = await ValidationTester.Test().RunAsync(async() => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r !.HasErrors); Assert.AreEqual(new DateTime(2020, 03, 01), ta.FromDate); Assert.AreEqual(new DateTime(2020, 04, 01), ta.ToDate); Assert.AreEqual(100m, ta.MinAmount); Assert.AreEqual(120m, ta.MaxAmount); Assert.AreEqual("Best Buy", ta.Text); }
public async Task A120_ArgsValidator_ToDateOnly() { var ta = new TransactionArgs { ToDate = new DateTime(2020, 03, 01) }; var r = await ValidationTester.Test().RunAsync(async() => await new TransactionArgsValidator().ValidateAsync(ta)); Assert.IsFalse(r !.HasErrors); Assert.AreEqual(new DateTime(2020, 03, 01).AddDays(-90), ta.FromDate); Assert.AreEqual(new DateTime(2020, 03, 01), ta.ToDate); Assert.IsNull(ta.MinAmount); Assert.IsNull(ta.MaxAmount); Assert.IsNull(ta.Text); }
public async Task A110_Validate_Initial() { await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "First Name is required.", "Email is required.", "Last Name is required.", "Gender is required.", "Birthday is required.", "Start Date is required.", "Phone No is required.") .CreateAndRunAsync <IValidator <Employee>, Employee>(new Employee()); }
public void A130_Validation_OK() { var p = new Person { FirstName = "Sam", LastName = "Reilly", GenderSid = "F", Birthday = DateTime.UtcNow.AddYears(-18) }; ValidationTester.Test() .AddScopedService(_referenceData) .Run(() => PersonValidator.Default.Validate(p)); }
public async Task A130_Validation_OK() { var p = new Person { FirstName = "Sam", LastName = "Reilly", GenderSid = "F", Birthday = DateTime.UtcNow.AddYears(-18) }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .CreateAndRunAsync <IValidator <Person>, Person>(p); }
public async Task A130_Validate_Address_Empty() { var e = CreateValidEmployee(); e.Address = new Address(); await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "Street1 is required.", "City is required.", "State is required.", "Post Code is required.") .CreateAndRunAsync <IValidator <Employee>, Employee>(e); }
public async Task A150_ArgsValidator_Invalid() { await ValidationTester.Test() .ExpectMessages( "Oldest time must be less than or equal to Newest time.", "Min Amount must be less than or equal to Max Amount.", "Text contains invalid or non-supported wildcard selection.") .RunAsync(async() => { var ta = new TransactionArgs { FromDate = new DateTime(2020, 03, 01), ToDate = new DateTime(2020, 02, 01), MinAmount = 100m, MaxAmount = 80m, Text = "Best*Buy" }; (await new TransactionArgsValidator().ValidateAsync(ta).ConfigureAwait(false)).ThrowOnError(); }); }
public void A130_Validate_Address_Empty() { var e = (Employee)ValidEmployee.Clone(); e.Address = new Address(); ValidationTester.Test() .AddScopedService(_referenceData) .ExpectMessages( "Street1 is required.", "City is required.", "State is required.", "Post Code is required.") .Run(() => EmployeeValidator.Default.Validate(e)); }
public async Task A150_Validate_Address_OK() { var e = CreateValidEmployee(); e.Address = new Address { Street1 = "8365 Rode Road", City = "Redmond", StateSid = "WA", PostCode = "98052" }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .CreateAndRunAsync <IValidator <Employee>, Employee>(e); }
public async Task A140_Validate_AfterTermination() { var pr = new PerformanceReview { EmployeeId = 2.ToGuid(), Date = DateTime.Now, OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages("Date must not be after the Employee has terminated.") .CreateAndRunAsync <IValidator <PerformanceReview>, PerformanceReview>(pr); }
public async Task A130_Validate_BeforeStarting() { var pr = new PerformanceReview { EmployeeId = 1.ToGuid(), Date = DateTime.Now.AddYears(-2), OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages("Date must not be prior to the Employee starting.") .CreateAndRunAsync <IValidator <PerformanceReview>, PerformanceReview>(pr); }
public void A130_Validate_Address_OK() { var e = (Employee)ValidEmployee.Clone(); e.Address = new Address { Street1 = "8365 Rode Road", City = "Redmond", StateSid = "WA", PostCode = "98052" }; ValidationTester.Test() .AddScopedService(_referenceData) .Run(() => EmployeeValidator.Default.Validate(e)); }
public async Task A170_Validate_CreateOK() { var pr = new PerformanceReview { EmployeeId = 2.ToGuid(), Date = DateTime.Now.AddMonths(-3), OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; // Need to set the OperationType to Create to exercise logic. await ValidationTester.Test() .ConfigureServices(_testSetup !) .OperationType(Beef.OperationType.Create) .CreateAndRunAsync <IValidator <PerformanceReview>, PerformanceReview>(pr); }
public void A130_Validate_Contacts_Empty() { var e = (Employee)ValidEmployee.Clone(); e.EmergencyContacts = new EmergencyContactCollection { new EmergencyContact() }; ValidationTester.Test() .AddScopedService(_referenceData) .ExpectMessages( "First Name is required.", "Last Name is required.", "Phone No is required.", "Relationship is required.") .Run(() => EmployeeValidator.Default.Validate(e)); }
public async Task A160_Validate_Contacts_Empty() { var e = CreateValidEmployee(); e.EmergencyContacts = new EmergencyContactCollection { new EmergencyContact() }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "First Name is required.", "Last Name is required.", "Phone No is required.", "Relationship is required.") .CreateAndRunAsync <IValidator <Employee>, Employee>(e); }
public void A140_Validate_AfterTermination() { var pr = new PerformanceReview { EmployeeId = 2.ToGuid(), Date = DateTime.Now, OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; ValidationTester.Test() .AddScopedService(_referenceData) .AddScopedService(_employeeManager) .ExpectMessages("Date must not be after the Employee has terminated.") .Run(() => PerformanceReviewValidator.Default.Validate(pr)); }
public void A130_Validate_BeforeStarting() { var pr = new PerformanceReview { EmployeeId = 1.ToGuid(), Date = DateTime.Now.AddYears(-2), OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; ValidationTester.Test() .AddScopedService(_referenceData) .AddScopedService(_employeeManager) .ExpectMessages("Date must not be prior to the Employee starting.") .Run(() => PerformanceReviewValidator.Default.Validate(pr)); }
public void A120_Validation_Invalid() { var p = new Person { FirstName = 'x'.ToLongString(), LastName = 'x'.ToLongString(), GenderSid = "X", Birthday = DateTime.UtcNow.AddDays(1) }; ValidationTester.Test() .AddScopedService(_referenceData) .ExpectMessages( "First Name must not exceed 100 characters in length.", "Last Name must not exceed 100 characters in length.", "Gender is invalid.", "Birthday must be less than or equal to Today.") .Run(() => PersonValidator.Default.Validate(p)); }
public async Task A140_Validate_Address_Invalid() { var e = CreateValidEmployee(); e.Address = new Address { Street1 = "8365 Rode Road", City = "Redmond", StateSid = "FR", PostCode = "XXXXXXXXXX" }; await ValidationTester.Test() .ConfigureServices(_testSetup !) .ExpectMessages( "State is invalid.", "Post Code is invalid.") .CreateAndRunAsync <IValidator <Employee>, Employee>(e); }
public void A130_Validate_Address_Invalid() { var e = (Employee)ValidEmployee.Clone(); e.Address = new Address { Street1 = "8365 Rode Road", City = "Redmond", StateSid = "FR", PostCode = "XXXXXXXXXX" }; ValidationTester.Test() .AddScopedService(_referenceData) .ExpectMessages( "State is invalid.", "Post Code is invalid.") .Run(() => EmployeeValidator.Default.Validate(e)); }
public void A170_Validate_CreateOK() { var pr = new PerformanceReview { EmployeeId = 2.ToGuid(), Date = DateTime.Now.AddMonths(-3), OutcomeSid = "ME", Reviewer = "*****@*****.**", Notes = "Thumbs up!" }; // Need to set the OperationType to Create to exercise logic. ValidationTester.Test() .OperationType(Beef.OperationType.Create) .AddScopedService(_referenceData) .AddScopedService(_employeeManager) .AddScopedService(_perfReviewManager) .Run(() => PerformanceReviewValidator.Default.Validate(pr)); }