public void TestObjectsTracking() { var tracker = new ObjectsChangeTracker(); var a = new A(); tracker.RegisterObject(a); a.f2 = 3; var changes = tracker.GetChanges(a); Assert.IsTrue(changes[0].name == "f2"); tracker.RegisterObject(a); changes = tracker.GetChanges(a); Assert.IsTrue(changes.Length == 0); a.f1 = "new"; a.f2 = 13; a.f3 = false; for (int i = 0; i < 10; ++i) { tracker.GetChanges(a); } changes = tracker.GetChanges(a); Assert.IsTrue(TestUtils.AreEqualArraysUnordered(new[] { "f1", "f2", "f3" }, changes.Select(c => c.name).ToArray())); changes = tracker.GetChanges(new A()); Assert.IsNull(changes); }
public void Nullity() { object act = new object(); // MSTest MSTestAssert.IsNull(act, "Some context"); // Assert.IsNull failed. Some context // NUnit Assert.That(act, Is.Null, () => "Some context"); // Some context // Expected: null // But was: <System.Object> // XUnit XUnitAssert.Null(act); // Assert.Null() Failure // Expected: (null) // Actual: Object { } // Fluent act.Should().BeNull("SOME REASONS"); // Expected act to be <null> because SOME REASONS, but found System.Object (HashCode=63566392). // Shouldly act.ShouldBeNull("Some context"); // act // should be null but was // System.Object (63566392) // // Additional Info: // Some context }
public void BuscarFailTest() { var controller = new DocenteController(); var result = controller.Get(10000); Assert.IsNull(result); }
public void TestRegistraUtente() { Utente utente = new UtenteNormale { Nome = "tizio", Cognome = "caio", Email = "*****@*****.**", LoginRemoto = true, Username = "******" }; utente.ImpostaPasswordDaOriginale("password"); // Verifico che non esista Assert.IsNull(gestioneUtentiController.ValidaCredenziali("tizio", "password")); // Lo registro, e verifico che adesso esiste Assert.IsTrue(gestioneUtentiController.Registra(utente)); IUtente utenteValidato = gestioneUtentiController.ValidaCredenziali("tizio", "password"); Assert.IsNotNull(utenteValidato); // Mi assicuro che sia del tipo giusto Assert.IsInstanceOfType(utenteValidato, typeof(UtenteNormale), "L'utente รจ di tipo sbagliato"); }
public void VerifyTimeOut() { CommandManager.CreateBrowserQueue(1); BrowserCommand c = new BrowserCommand(); UnitTestAssert.IsNull(CommandManager.ExecuteCommand(1, c, 0)); }
public void CopyPropertiesTest1() { var pi1 = new PhoneItem() { FaxNumber = "456598784532", PhoneNumber = "124565789854" }; var pi2 = new PhoneItem() { FaxNumber = "789874654312", PhoneNumber = "684763251325" }; var phoneItems = new List <PhoneItem>() { pi1, pi2 }; var address = new Address() { Id = 1, City = "Rennes", Street = "rue de la paix" }; var objOrigin = new Employee { Id = 0, Name = "Bernard", Password = "******", Address = address, PhoneItems = phoneItems }; var objDestination = new Customer(); CopyUtils.CopyProperties(objDestination, objOrigin); Assert.IsTrue(objDestination.Id.Equals(objOrigin.Id)); Assert.IsNull(objDestination.GetName()); Assert.IsNull(objDestination.Address); Assert.IsNull(objDestination.Emails); }
public void WhenSubmit_ShouldSendSubmitCommand() { //arrange var html = @" <html> <body> <form id='form1'> <input type='hidden' id='input1' value='thevalue' /> </form> </body> </html>"; MockCommandExecutor commandExecutor = new MockCommandExecutor(); _commandExecutorFactory.Setup(m => m.CreateBrowserCommandExecutor(It.IsAny <string>(), It.IsAny <HtmlPage>())).Returns(commandExecutor); var testPage = new HtmlPage(); var document = HtmlElement.Create(html, testPage, false); //act var form = (HtmlFormElement)document.ChildElements.Find("form1"); form.Submit(); //assert MSAssert.AreEqual("FormSubmit", commandExecutor.ExecutedCommands[0].Handler.ClientFunctionName); MSAssert.AreEqual("FormSubmit", commandExecutor.ExecutedCommands[0].Description); MSAssert.IsTrue(commandExecutor.ExecutedCommands[0].Handler.RequiresElementFound); MSAssert.AreEqual("form1", commandExecutor.ExecutedCommands[0].Target.Id); MSAssert.IsNull(commandExecutor.ExecutedCommands[0].Handler.Arguments); }
public void TestTwoVersionOfObjects() { var tracker = new ObjectsChangeTracker(); var original = new A() { f1 = "f1", f2 = 2, f3 = true }; var current = new A() { f1 = "f0", f2 = 2, f3 = false }; var changes = tracker.GetChanges(original, current); Assert.AreEqual(2, changes.Count()); Assert.AreEqual("f1", changes[0].name); Assert.AreEqual("f0", changes[0].CurrentValue); Assert.AreEqual("f3", changes[1].name); Assert.AreEqual(false, changes[1].CurrentValue); changes = tracker.GetChanges(original, null); Assert.IsNull(changes); changes = tracker.GetChanges(null, current); Assert.IsNull(changes); }
public void DefaultAuditorCalledForNonSpecificTypeUpdate() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject bar = GetTestService("Bars").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int defaultUpdatedCount = 0; int defaultPersistedCount = 0; string newValue = Guid.NewGuid().ToString(); MyDefaultAuditor.Auditor.objectPersistedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Bar", o.GetType().GetProxiedType().FullName); Assert.IsNull(((Bar)o).Prop1); defaultPersistedCount++; }; bar.Save(); MyDefaultAuditor.Auditor.objectUpdatedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Bar", o.GetType().GetProxiedType().FullName); Assert.AreEqual(newValue, ((Bar)o).Prop1); defaultUpdatedCount++; }; NakedObjectsFramework.TransactionManager.StartTransaction(); bar.GetPropertyByName("Prop1").SetValue(newValue); NakedObjectsFramework.TransactionManager.EndTransaction(); Assert.AreEqual(1, defaultUpdatedCount, "expect default auditor to be called for updates"); Assert.AreEqual(1, defaultPersistedCount, "expect default auditor to be called for persists"); }
public void ConstructorToNotCreateTestFromTemplateTest() { bool fromTemplate = false; _testEditorAccessor = new TestEditor_Accessor(fromTemplate); Assert.IsNull(_testEditorAccessor._configurationTestSuite); }
public void FindTestNotFound() { CustomerRepository repository = new CustomerRepository(); var customerList = repository.Retrieve(); var result = repository.Find(customerList, 42); Assert.IsNull(result); }
public void ConvertObjectToDictionaryReturnsNullWhenPassedNull() { //Arrange & Act Dictionary <string, object> d = HtmlElementFindParams.ConvertObjectToDictionary(null); //Assert UnitTestAssert.IsNull(d); }
public void Initialize() { MockAspNetService mockAspNetService = new MockAspNetService(); SystemWebExtensionsWrapper swe = new SystemWebExtensionsWrapper(mockAspNetService); UnitTestAssert.IsNull(swe.RegisterStartupScriptMethodInfo); swe.Initialize(new Page()); UnitTestAssert.IsNotNull(swe.RegisterStartupScriptMethodInfo); }
public void LineGrazesSphereButDoesNotIntersect() { var sphere = new Sphere(Vector.Zero, 1.0); Sphere.LatLong spherePt1, spherePt2; sphere.IntersectLine(Vector.Forward, Vector.Right + Vector.Forward, out spherePt1, out spherePt2); Assert.IsNull(spherePt1); Assert.IsNull(spherePt2); }
public void GetStringTest() { JobParameters jp = TearUp(); string dval = jp.GetString("p1"); Assert.AreEqual("param1", dval); string dval2 = jp.GetString("unknownkey"); Assert.IsNull(dval2); }
public override void TestParseEmptyString() { try { object newValue = value.ParseTextEntry(""); Assert.IsNull(newValue); } catch (Exception) { Assert.Fail(); } }
public void GetDateTest() { JobParameters jp = TearUp(); DateTime? dval = jp.GetDate("p4"); Assert.IsNotNull(dval); Assert.AreEqual(DateTime.Parse("1970-07-31"), dval); DateTime?dval2 = jp.GetDate("unknownkey"); Assert.IsNull(dval2); }
public void AgregarFailCatchTest() { Docente docente = new Docente() { TipoDocumentoId = 1, FechaNacimiento = DateTime.Now, Sexo = "Masculino" }; var result = controller.Post(docente); Assert.IsNull(result); }
public void DefaultValues() { QueryStringParameters p = new QueryStringParameters(); UnitTestAssert.AreEqual(WebTestLogDetail.Default, p.LogDetail); UnitTestAssert.IsNull(p.Tag); UnitTestAssert.IsFalse(p.Filter); UnitTestAssert.IsFalse(p.Run); UnitTestAssert.IsFalse(p.SkipFail); UnitTestAssert.IsFalse(p.WriteLog); UnitTestAssert.IsTrue(p.ShowConsole); }
public void ItemPresentInBasketCanBeRemoved() { var sut = new Basket(); sut.AddItem(_catalogueItemId, _unitPrice, _quantity); sut.RemoveItem(_catalogueItemId); var item = sut.Items.FirstOrDefault(); Assert.IsNull(item); }
public void OnInit_NoUI() { MockAspNetService mockAspNet = new MockAspNetService(); mockAspNet.SetIsPostBack(false); TestDriverPage page = new TestDriverPage(mockAspNet); page.TestCasesTreeView = new System.Web.UI.WebControls.TreeView(); page.AutoGenerateInterface = false; page.OnInitInternal(); UnitTestAssert.IsNull(page.ThreadIdLabel); }
public void TestEliminaUtente() { // Ottengo l'admin IUtente admin = gestioneUtentiController.ValidaCredenziali("admin", "admin"); Assert.IsNotNull(admin); // Lo elimino Assert.IsTrue(gestioneUtentiController.Elimina((Utente)admin)); // Verifico che sia stato eliminato admin = gestioneUtentiController.ValidaCredenziali("admin", "admin"); Assert.IsNull(admin); }
public void OnInit_NoLocators() { ServiceLocator.ApplicationPathFinder = null; ServiceLocator.BrowserCommandExecutorFactory = null; MockAspNetService mockAspNet = new MockAspNetService(); mockAspNet.SetIsPostBack(true); TestDriverPage page = new TestDriverPage(mockAspNet); page.TestCasesTreeView = new System.Web.UI.WebControls.TreeView(); page.AutoGenerateInterface = false; page.OnInitInternal(); UnitTestAssert.IsNull(ServiceLocator.ApplicationPathFinder); UnitTestAssert.IsNull(ServiceLocator.BrowserCommandExecutorFactory); }
public void Normalize_NodeWithLeftAndRightLeavesWithEqualValue_NodeBecomesLeafWithValueOfLeft() { var target = new Event { IsLeaf = false, Left = new Event(), Right = new Event() }; target.Left.Value = 5; target.Right.Value = 5; target.Normalize(); Assert.AreEqual(5, target.Value); Assert.IsNull(target.Left); Assert.IsNull(target.Right); }
public void PropertyTest_NullPropagation() { var f = TypeAdapter.Adapt <C, F>(new C { BClass = new B { Total = 250 } }); Assert.IsNotNull(f); Assert.IsTrue(f.BClass_Total == 250); var f2 = TypeAdapter.Adapt <C, F>(new C { BClass = null }); Assert.IsNotNull(f2); Assert.IsNull(f2.BClass_Total); }
public void MoveEnvelopes_CorrectInputParameters_ReturnFolderResponse() { CreateEnvelopeMethod.CreateEnvelope_CorrectAccountIdAndEnvelopeDefinition_ReturnEnvelopeSummary(ref _testConfig); var envelopesApi = new EnvelopesApi(_testConfig.ApiClient); Envelope envelope = envelopesApi.GetEnvelope(_testConfig.AccountId, _testConfig.EnvelopeId); Assert.IsNull(envelope?.VoidedDateTime); var foldersRequest = new FoldersRequest(new List <string> { _testConfig.EnvelopeId }); var ToFolderId = "recyclebin"; _foldersApi.MoveEnvelopes(_testConfig.AccountId, ToFolderId, foldersRequest); envelope = envelopesApi.GetEnvelope(_testConfig.AccountId, _testConfig.EnvelopeId); Assert.IsNotNull(envelope?.VoidedDateTime); }
public async Task QuestionDeleteCommandTriggersEventToDeleteQuestionFromQueryDb() { //Arrange var command = new QuestionCreateCommand("Test Question 1"); await _commandBus.Send(command); var questions = await _questionRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false); var question = questions.FirstOrDefault(); //Act Assert.IsNotNull(question); var command2 = new QuestionDeleteCommand(1, 0); await _commandBus.Send(command2).ConfigureAwait(false); var questionAfterDelete = (await _questionRepo.FindByAsync(q => q.Id == 1).ConfigureAwait(false)).FirstOrDefault(); //Act Assert.IsNull(questionAfterDelete); }
public void AuditUsingSpecificTypeAuditorUpdateQux() { MyDefaultAuditor.SetActionCallbacksExpected(); ITestObject qux = GetTestService("Quxes").GetAction("New Instance").InvokeReturnObject(); MyDefaultAuditor.SetActionCallbacksUnexpected(); int quxUpdatedCount = 0; int quxPersistedCount = 0; string newValue = Guid.NewGuid().ToString(); QuxAuditor.Auditor.objectPersistedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Qux", o.GetType().GetProxiedType().FullName); Assert.IsNull(((Qux)o).Prop1); quxPersistedCount++; }; qux.Save(); QuxAuditor.Auditor.objectUpdatedCallback = (p, o) => { Assert.AreEqual("sven", p.Identity.Name); Assert.IsNotNull(o); Assert.AreEqual("NakedObjects.SystemTest.Audit.Qux", o.GetType().GetProxiedType().FullName); Assert.AreEqual(newValue, ((Qux)o).Prop1); quxUpdatedCount++; }; NakedObjectsFramework.TransactionManager.StartTransaction(); qux.GetPropertyByName("Prop1").SetValue(newValue); NakedObjectsFramework.TransactionManager.EndTransaction(); Assert.AreEqual(1, quxUpdatedCount, "expect qux auditor to be called for updates"); Assert.AreEqual(1, quxPersistedCount, "expect qux auditor to be called for persists"); }
public void CopyPropertiesTest2() { var address = new CompleteAddress() { Id = 0, City = "Rennes", Street = "rue de la paix", State = 33, Country = "France" }; var email1 = "*****@*****.**"; var email2 = "*****@*****.**"; var emails = new List <string>() { email1, email2 }; var objOrigin = new Customer { Id = 0, Address = address, Emails = emails }; var objDestination = new Employee(); CopyUtils.CopyProperties(objDestination, objOrigin); Assert.IsTrue(objDestination.Id.Equals(objOrigin.Id)); Assert.IsNull(objDestination.Name); Assert.IsTrue(objDestination.Address.Equals(objOrigin.Address)); }
public void EnumeratorTest() { var listeners = TearUp(); IEnumerator <IStepListener> enumerator = listeners.Enumerator(); Assert.IsNotNull(enumerator); int i = 1; while (enumerator.MoveNext()) { object item = enumerator.Current; switch (i) { case 1: Assert.IsTrue(item is FirstListener); Assert.AreEqual(1, OrderHelper.GetOrderFromAttribute(item).Value); break; case 2: Assert.IsTrue(item is SecondListener); Assert.AreEqual(2, OrderHelper.GetOrderFromAttribute(item).Value); break; case 3: Assert.IsTrue(item is ThirdListener); Assert.AreEqual(3, OrderHelper.GetOrderFromAttribute(item).Value); break; case 4: Assert.IsTrue(item is UnorderedListener); Assert.IsNull(OrderHelper.GetOrderFromAttribute(item)); break; } i++; } }