public void AreEqual_EquivalentIntAndLong_NothingHappens() { int i = 99; long l = 99; AssertThat.AreEqual(i, l); }
public void AreEqual_NotEquivalentIntAndLong_ThrowsAssertionException() { int i = 99; long l = 98; AssertThat.AreEqual(i, l); }
public void Add_Contact_To_Organization_Contact_List() { ContactCreator.CreateSimpleOrphanContact(); OrganizationCreator.CreateSimpleOrganization(); OrganizationViewPage.AddContactsToContactList().WithFirstName(ContactCreator.FirstContact.FirstName).AndLastName(ContactCreator.FirstContact.LastName).Add(); OrganizationsPage.FindOrganization().WithOrganizationName(OrganizationCreator.FirstOrganization.OrganizationName).Open(); AssertThat.IsTrue( OrganizationViewPage.FindContactFromOrganizationContactList() .WithFirstName(ContactCreator.FirstContact.FirstName) .AndLastName(ContactCreator.FirstContact.LastName) .Find(), $"Contact {ContactCreator.FirstContact.FullName} does not exist within organization {OrganizationCreator.FirstOrganization.OrganizationName} contacts, although it was added previously"); OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(1).Remove(); AssertThat.IsFalse( OrganizationViewPage.FindContactFromOrganizationContactList() .WithFirstName(ContactCreator.FirstContact.FirstName) .AndLastName(ContactCreator.FirstContact.LastName) .Find(), $"Contact {ContactCreator.FirstContact.FullName} exists within organization {OrganizationCreator.FirstOrganization.OrganizationName} contacts, although it was removed previously"); ContactsPage.FindContact().WithFirstName(ContactCreator.FirstContact.FirstName).AndLastName(ContactCreator.FirstContact.LastName).Open(); AssertThat.AreEqual(ContactViewPage.OrganizationName, "", $"Contact {ContactCreator.FirstContact.FullName} is not orphan though it should because it was removed from organization '{OrganizationCreator.FirstOrganization.OrganizationName}' contacts"); }
public void update_value_object_with_direct_context() { UserTestData.PrepareUser(userId); string houseNo = Guid.NewGuid().ToString("n"); using (var kernel = new Ninject.StandardKernel()) { kernel.ConfigureDirectContext(); var orderingService = kernel.Get <IOrderingService>(); // ACT orderingService.SetUserAddress(userId, new Address() { City = "Poznań", HouseNo = houseNo, Street = "Brzęczyszczykiewicza" }); } using (var db = new MyContext()) { var user = db.Users.FirstOrDefault(u => u.Id == userId); // ups, we updated the object, but didn't reattach it to the new context! AssertThat.AreEqual(houseNo, user.Address.HouseNo); } }
public void Organization_Name_Navigates_To_Organization_View() { ContactCreator.CreateSimpleContact(); ContactViewPage.ClickOrganizationName(); AssertThat.AreEqual(ContactCreator.FirstContact.OrganizationName, OrganizationViewPage.OrganizationName, $"Browser should navigate to '{ContactCreator.FirstContact.OrganizationName}' organization view but, it did not"); }
public void AreEqual_TwoLogicallyEqualDateTimes_NothingHappens() { var d1 = new DateTime(2009, 5, 19, 9, 18, 50, 99); var d2 = new DateTime(2009, 5, 19, 9, 18, 50, 11); AssertThat.AreEqual(d1, d2); }
public void Cannot_Assign_Invalid_Organization_After_Edit() { ContactCreator.CreateSimpleContact(); ContactCreator.EditContactAssigningInvalidOrganization(ContactCreator.FirstContact); AssertThat.IsTrue(ContactCreator.FirstContact.IsContactSavedAfterEdit, "Contact was not saved after edit but, it should."); AssertThat.AreEqual(ContactViewPage.OrganizationName, "", $"Organization ought to be null but it has value = '{ContactViewPage.OrganizationName}' which is invalid. Defect spotted!"); }
public void Cannot_Assign_Invalid_Organization_Field_Value() { ContactCreator.CreateContactWithInvalidOrganization(); AssertThat.IsTrue(ContactCreator.FirstContact.IsContactCreatedSuccessfully, "Contact was not created successfully though it should. Defect spotted!"); AssertThat.AreEqual(ContactViewPage.OrganizationName, "", $"Organization ought to be null but it has value = '{ContactViewPage.OrganizationName}' which is invalid. Defect spotted!"); }
public void Import_Organization_That_Already_Exist_Within_Contacts() { OrganizationCreator.ImportTemplateWithAnExistingOrganization(); AssertThat.IsTrue(OrganizationCreator.IsOrganizationFileImportedWithDuplicates, "At least one of the 2 duplicate organizations should have been imported but neither did."); OrganizationsPage.FindOrganization() .WithOrganizationName(OrganizationCreator.FirstOrganization.OrganizationName) .Find(); AssertThat.AreEqual(OrganizationsPage.TotalOrganizationsCountByLabel, 1, $"There should be only one organization with name '{OrganizationCreator.FirstOrganization.OrganizationName}' being displayed. It seems that the second twin organization was imported successfully"); }
public void Import_Contact_That_Already_Exists() { ContactCreator.ImportOutlookCsvContactsThatAlreadyExists(); AssertThat.IsTrue(ContactCreator.IsContactFileImportedWithDuplicates, "Contact was imported successfully but it does not contain value for last name field"); ContactsPage.FindContact() .WithFirstName(ContactCreator.FirstContact.FirstName) .AndLastName(ContactCreator.FirstContact.LastName) .Find(); AssertThat.AreEqual(ContactsPage.TotalContactsCountByLabel, 1, $"There should be only one contact with name '{ContactCreator.FirstContact.FullName}' being displayed. It seems that the second twin contact was imported successfully"); }
public void Import_Contact_That_Already_Exist_Within_Contacts() { ContactCreator.ImportTemplateWithAnExistingContact(); AssertThat.IsTrue(ContactCreator.IsContactFileImportedWithDuplicates, "At least one of the 2 duplicate contacts should have been imported but neither did."); ContactsPage.FindContact() .WithFirstName(ContactCreator.FirstContact.FirstName) .AndLastName(ContactCreator.FirstContact.LastName) .Find(); AssertThat.AreEqual(ContactsPage.TotalContactsCountByLabel, 1, $"There should be only one contact with name '{ContactCreator.FirstContact.FullName}' being displayed. It seems that the second twin contact was imported successfully"); }
public void Make_A_Contact_Primary_From_Within_Organization() { OrganizationCreator.CreateSimpleOrganization(); OrganizationViewPage.AddContactsToContactList().Randomly(2).Add(); AssertThat.AreEqual(OrganizationViewPage.ContactListCount, 2, "Previously added contacts did not show up in organization contact list"); OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(1).MakePrimaryContact(); AssertThat.AreEqual(OrganizationViewPage.PrimaryContact, OrganizationViewPage.GetContactFullNameBySequence(1), $"Contact '{OrganizationViewPage.GetContactFullNameBySequence(1)}' was not made primary though it should"); OrganizationViewPage.FindContactFromOrganizationContactList().BySequence(2).MakePrimaryContact(); AssertThat.AreEqual(OrganizationViewPage.PrimaryContact, OrganizationViewPage.GetContactFullNameBySequence(2), $"Contact '{OrganizationViewPage.GetContactFullNameBySequence(2)}' was not made primary though it should"); }
public void ZiperTest() { string str = null; AssertThat.DoesNotThrowException(() => { str = Ziper.TempPath; }); AssertThat.IsTrue(Directory.Exists(str)); Directory.CreateDirectory("Test"); File.WriteAllText(@"Test\Test", "Test"); AssertThat.DoesNotThrowException(() => { Ziper.Zip("Test.zip", "Test"); }); AssertThat.DoesNotThrowException(() => { Ziper.UnZip("Test.zip", "Test-copy"); }); AssertThat.AreEqual(File.ReadAllText(@"Test-copy\Test"), IS.a("Test")); File.Delete("Test.zip"); Directory.Delete("Test", true); Directory.Delete("Test-copy", true); }
public void make_order_without_transaction_leaves_inconsistent_db() { UserTestData.PrepareUser(userId); int initialCount; int initialUserCount; using (var db = new MyContext()) { initialCount = db.Orders.Count(o => o.UserId == userId); initialUserCount = db.Users.Find(userId).OrdersCount; } MyContext.ResetCounters(); using (var kernel = new Ninject.StandardKernel()) { kernel.BindServices() .UseContextDirectly() .UseNoTransactions(); var orderingService = kernel.Get <OrderingService>(); orderingService.ShouldThrowAfterOrderAdd = true; try { // ACT MakeOrder(kernel.Get <IOrderingService>()); Assert.Fail("expected exception"); } catch { // ignore } } Assert.AreEqual(1, MyContext.TotalInstancesCreated); Assert.AreEqual(0, MyContext.InstanceCount); using (var db = new MyContext()) { var user = db.Users.Find(userId); var ordersCount = db.Orders.Count(o => o.UserId == userId); Assert.AreEqual(initialUserCount, user.OrdersCount); // will be incosistent: AssertThat.AreEqual(initialCount, ordersCount, AssertOutcome.Inconclusive); } }
public void CSVEditorTest() { EditorTest et = new EditorTest( "A,B,C,D" + "\r\n" + "E,,F,G" + "\r\n" + "H,,I,J" + "\r\n" + "K,,L,\"M,N\"" + "\r\n" + "\r\n" ); ForLine fl = (Line, nb) => new string[] { Line["A"], Line["D"], Line["B"], "C" }; Edit(et, fl).Wait(); AssertThat.AreEqual(et.Out, IS.a( "A,D,B,C" + "\r\n" + "E,G,,C" + "\r\n" + "H,J,,C" + "\r\n" + "K,\"M,N\",,C" + "\r\n" )); }
public void GetInstance_CustomLifestyleRegistrationWrappedWithProxyDecorator_DecoratorContextGetsSuppliedWithCorrectImplementationType() { // Arrange Type expectedImplementationType = typeof(ConcreteCommandHandler); Type actualImplementationType = null; var container = new Container(); container.Register <ICommandHandler <ConcreteCommand>, ConcreteCommandHandler>(CustomLifestyle); container.RegisterSingleDecorator(typeof(ICommandHandler <>), typeof(AsyncCommandHandlerProxy <>), c => { actualImplementationType = c.ImplementationType; return(true); }); // Act container.GetInstance <ICommandHandler <ConcreteCommand> >(); // Assert AssertThat.AreEqual(expectedImplementationType, actualImplementationType); }
public void update_related_entity_with_direct_context() { UserTestData.PrepareUser(userId); string itemName = $"item-{Guid.NewGuid()}"; using (var kernel = new Ninject.StandardKernel()) { kernel.ConfigureDirectContext(); var orderingService = kernel.Get <IOrderingService>(); // ACT orderingService.SetUserPreferences(userId, itemName); } using (var db = new MyContext()) { var user = db.Users.Include(u => u.UserPreferences).FirstOrDefault(u => u.Id == userId); // ups, we updated the object, but didn't reattach it to the new context! AssertThat.AreEqual(itemName, user.UserPreferences.FavoriteProduct); } }
protected override void EqualsCore(string columnName, object compareWith, string failedAssertionMessage) { AssertThat.AreEqual(compareWith, ExecutionResult.GetResult(columnName.ToUpper()), failedAssertionMessage); }
public void Select_Multiple_Contacts() { ContactsPage.SelectRandomNumberOfContacts(); AssertThat.AreEqual(ContactsPage.SelectedContactsCount, ContactsPage.SelectedContactsCountByLabel, "The count of selected contacts is not equal with the value of the corresponding label"); }
public void Check_Contacts_Displayed_Is_Equal_To_Label() { AssertThat.AreEqual(ContactsPage.TotalContactsCountByLabel, ContactsPage.TotalContactsCount, "The count of contacts being displayed is not equal with the value of the corresponding label"); }
public void AreEqual_TwoEqualStrings_NothingHappens() { AssertThat.AreEqual("s", "s"); }
public void Select_Multiple_Organizations() { OrganizationsPage.SelectRandomNumberOfOrganizations(); AssertThat.AreEqual(OrganizationsPage.SelectedOrganizationsCountByLabel, OrganizationsPage.SelectedOrganizationsCount, "The count of selected organizations is not equal with the value of the corresponding label"); }
public void AreEqual_TwoNulls_NothingHappens() { AssertThat.AreEqual(null, null); }
public void AreEqual_TwoNonEqualDateTimes_ThrowsAssertionException() { AssertThat.AreEqual(new DateTime(1999, 12, 12, 12, 12, 12, 12), new DateTime(1999, 11, 12, 12, 12, 12, 12)); }
public void AreEqual_TwoNonEqualStrings_ThrowsAssertionException() { AssertThat.AreEqual("s", "s1"); }
public void Check_Coworkers_Displayed_Is_Equal_To_Label() { LeftSideMenu.GoToCoworkers(); AssertThat.AreEqual(CoworkersPage.TotalCoworkersCountByLabel, CoworkersPage.TotalCoworkersCount, "The count of coworkers being displayed is not equal with the value of the corresponding label"); }
public void AreEqual_TwoEqualDateTimes_NothingHappens() { AssertThat.AreEqual(new DateTime(1999, 12, 12, 12, 12, 12, 12), new DateTime(1999, 12, 12, 12, 12, 12, 12)); }
public void AreEqual_DifferentTypes_ThrowsAssertionException() { AssertThat.AreEqual("string", DateTime.Now); }