public void GetAllTransportationInfsTest() { //Arrange var mock = new Mock <ITransportationInfRepository>(); mock.Setup(j => j.GetAllTransportationInfs()).Returns(ListTransportationInfData); var repo = mock.Object; // Action var result = repo.GetAllTransportationInfs(); var listTransportation = ListTransportationInfData(); // Assert Assert.AreEqual(result.ToString(), listTransportation.ToString()); //Arrange var mockNull = new Mock <ITransportationInfRepository>(); if (mockNull.Object == null) { var repoNull = mockNull.Object; // Action var resultNull = repoNull.GetAllTransportationInfs(); // Assert Assert.IsNull(resultNull); } }
public void TestServerTaskCancelledResultsInNoViewBeingShown() { // arrange iServer.ForceCancelTask = true; // simulate a cancellation var waitHandle = new AutoResetEvent(false); iServer.CheckCallback = (response) => { iInvoker.BeginInvoke(new Action(() => { waitHandle.Set(); })); }; iView.ShowCallback = (notification, shownow) => { Assert.Fail("View show should not be called"); }; // act using (var controller = new NotificationController(iInvoker, iPersistence, iServer, iView, NotificationController.DefaultTimespan)) { Assert.That(waitHandle.WaitOne(kTimeoutMilliseconds)); } // flush pending invocations AwaitInvoker(); // assert Assert.IsNull(iView.Current); Assert.IsNull(iView.LastShown); Assert.AreEqual(iPersistence.LastNotificationVersion, 0); }
public void TestNotificationIsNotShownIfAlreadySeen() { // arrange iPersistence.LastNotificationVersion = 1; iPersistence.LastShownNotification = DateTime.Now; iServer.SetDesiredResponse(iServerResponseV1); var waitHandle = new AutoResetEvent(false); iView.ShowCallback = (notification, shownow) => { if (shownow) { Assert.Fail("View should not be shown."); } waitHandle.Set(); }; // act using (var controller = new NotificationController(iInvoker, iPersistence, iServer, iView, NotificationController.DefaultTimespan)) { Assert.That(waitHandle.WaitOne(kTimeoutMilliseconds)); } // flush pending invocations AwaitInvoker(); // assert Assert.IsNotNull(iView.Current); Assert.IsNull(iView.LastShown); Assert.AreEqual(iPersistence.LastNotificationVersion, iNotificationVersion1.Version); }
public void GetTransportationInfByShippingIdTest() { var transportationInf = TransportationInfData(); var mockRepository = new Mock <ITransportationInfRepository>(); mockRepository.Setup(x => x.GetTransportationInfById(1)).Returns(transportationInf); // Act var controller = new TransportationInfController(mockRepository.Object); // Assert var result = controller.GetTransportationInfByShippingId(1) as TransportationInf; if (result != null) { Assert.AreEqual(result, transportationInf); } // Arrange var transportationInfNull = new TransportationInf(); var mockRepositoryNull = new Mock <ITransportationInfRepository>(); mockRepositoryNull.Setup(x => x.GetTransportationInfById(50)).Returns(transportationInfNull); // Act var controllerNull = new TransportationInfController(mockRepositoryNull.Object); // Assert var resultNull = controllerNull.GetTransportationInfByShippingId(50) as TransportationInf; Assert.IsNull(resultNull); }
public void GetJobAssignmentByIdTest() { //Arrange var tranA = TransportationInfData(); var mock = new Mock <ITransportationInfRepository>(); mock.Setup(j => j.GetTransportationInfById(1)).Returns(tranA); var repo = mock.Object; // Action var result = repo.GetTransportationInfById(1); // Assert Assert.AreEqual(result.ToString(), tranA.ToString()); //Arrange var mockNull = new Mock <ITransportationInfRepository>(); if (mockNull.Object == null) { var repoNull = mockNull.Object; // Action var resultNull = repoNull.GetTransportationInfById(null); // Assert Assert.IsNull(resultNull); } }
public void MissingSessionValueShouldReturnNull() { var builder = new TestControllerBuilder(); object o = builder.Session["Variable"]; Assert.IsNull(o); }
public void Generic_Constructor_Success_Test() { var r = new CallResult <int>(true); Assert.IsTrue(r.Success); Assert.IsNull(r.Exception); }
public void RequestNonExistingItem() { StubMockStyleDictionary testee = new StubMockStyleDictionary(); Mock <IMockObject> mock = mockFactory.CreateMock <IMockObject>(); Assert.IsNull(testee[mock.MockObject, typeof(IHelloWorld)]); }
public void GetAllJobAssignmentsTest() { //Arrange var mock = new Mock <IJobAssignmentRepository>(); mock.Setup(j => j.GetAllJobAssignments()).Returns(ListJobAssignmentData); var repo = mock.Object; // Action var result = repo.GetAllJobAssignments(); var listJob = ListJobAssignmentData(); // Assert Assert.AreEqual(result.ToString(), listJob.ToString()); //Arrange var mockNull = new Mock <IJobAssignmentRepository>(); if (mockNull.Object == null) { var repoNull = mockNull.Object; // Action var resultNull = repoNull.GetAllJobAssignments(); // Assert Assert.IsNull(resultNull); } }
public void RemoveFromCacheNotThere() { HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session; session.ClearFromSession("key1"); Assert.IsNull(session.GetObjectFromSession <Claim>(Surface, "key1")); }
public void TestUnpackArray_ByteArray_Null_Nil() { var result = Unpacking.UnpackArray(new byte[] { 0xC0 }); Assert.AreEqual(1, result.ReadCount); Assert.IsNull(result.Value); }
public void CachedValuesOfDifferentType() { HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session; session.AddValueToSession("key1", 1); Assert.IsNull(session.GetValueFromSession <long>("key1")); }
public void TestUnpackNull_ByteArray_Offset_OffsetIsValid_OffsetIsRespected() { var result = Unpacking.UnpackNull(new byte[] { 0xFF, 0xC0, 0xFF }, 1); Assert.AreEqual(1, result.ReadCount); Assert.IsNull(result.Value); }
public void TestStationFinderNullInput() { Suggestions response = _stationFinder.GetSuggestions(null).Result; Assert.IsNull(response.NextLetters); Assert.IsNull(response.Stations); }
public void ListJobAssignmentByTruckDriverIdTest() { // Arrange var job = ListJobAssignmentData(); var mockRepository = new Mock <IJobAssignmentRepository>(); mockRepository.Setup(x => x.GetListJobByTruckDriverId(1)).Returns(job); // Act var controller = new JobAssignmentController(mockRepository.Object); // Assert var result = controller.ListJobAssignmentByTruckDriverId(1) as List <JobAssignment>; if (result != null) { Assert.AreEqual(result, job); } // Arrange var jobNull = new List <JobAssignment>(); var mockRepositoryNull = new Mock <IJobAssignmentRepository>(); mockRepositoryNull.Setup(x => x.GetListJobByTruckDriverId(30)).Returns(jobNull); // Act var controllerNull = new JobAssignmentController(mockRepositoryNull.Object); // Assert var resultNull = controllerNull.ListJobAssignmentByTruckDriverId(30) as List <JobAssignment>; Assert.IsNull(resultNull); }
public void GetMissingAnnotationReturnsNull() { var cq = CQ.Create("<div></div>"); object value = cq.FirstElement().Annotations.GetAnnotation("missing"); Assert.IsNull(value, "value was not null"); }
public void Case1() { PieceMovement pieceMovement = new PieceMovement(new IntegerVector2(0, 1), 1); Assert.IsNotNull(pieceMovement.GetPath(new IntegerVector2(0, 1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(1, 1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-1, 1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(0, -1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-1, 0))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(1, 0))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(1, -1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-1, -1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-2, 2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-1, 2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(0, 2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(1, 2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(2, 2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-2, 1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(2, 1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-2, 0))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(2, 0))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-2, -1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(2, -1))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-2, -2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(-1, -2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(0, -2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(1, -2))); Assert.IsNull(pieceMovement.GetPath(new IntegerVector2(2, -2))); }
public void Generic_DefaultConstructorTest() { var r = new CallResult <int>(); Assert.IsFalse(r.Success); Assert.IsNull(r.Exception); }
public void NullObjectCheck(int MedicineStripCount, DateTime LaunchDate, string RetailerAddress) { Medicine medicine1 = null; var cartonCheck = program.CreateCartonDetail(MedicineStripCount, LaunchDate, RetailerAddress, medicine1); Assert.IsNull(cartonCheck); }
public void TestInvalidID() { string html = @"<img alt="""" id=""Picture 7"" src=""Image.aspx?imageId=26381"" style=""border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; margin-left: 1px; margin-right: 1px; width: 950px; height: 451px; "" />"; var dom = CQ.Create(html); var res = dom["img"]; Assert.AreEqual(1, res.Length); Assert.AreEqual("Picture 7", res[0].Id); var img = dom.Document.GetElementById("Picture 7"); Assert.IsNotNull(img); Assert.AreEqual("Picture 7", img.Id); img = dom.Document.GetElementById("Picture"); Assert.IsNull(img); dom = CQ.Create("<body><div></div><img id=\"image test\" src=\"url\"/>content</div></body>"); res = dom["img"]; Assert.AreEqual(1, res.Length); Assert.AreEqual("image test", res[0].Id); }
public void TestSendMessage() { var controller = new HomeController(); var result = controller.SendMessage(); Assert.IsNull(result); }
public void GetExpositionInfo_return_null_when_Exposition_not_found() { int id = 0; var result = _expositionService.GetExpositionInfo(id); Assert.IsNull(result); }
public void StoresResultToReturn() { invocation.Result = result; Assert.AreSame(result, invocation.Result, "should store result"); Assert.IsFalse(invocation.IsThrowing, "should not be throwing"); Assert.IsNull(invocation.Exception, "should not store an exception"); }
public void StoresExceptionToThrow() { invocation.Exception = exception; Assert.AreSame(exception, invocation.Exception, "should store exception"); Assert.IsTrue(invocation.IsThrowing, "should be throwing"); Assert.IsNull(invocation.Result, "should not store a result"); }
public void InvokeActionByLambdaWithInvalidParms() { bool valid; IQueryable <Employee> result = controller.InvokeAction <EmployeeRepository, string, string, IQueryable <Employee> >(EmployeeRepo.GetDomainObject <EmployeeRepository>(), x => x.FindEmployeeByName, new FormCollection(), out valid); Assert.IsNull(result); Assert.IsFalse(valid); }
public void CheckDivideFailTest() { double div1 = 50.3; double div2 = 11.5; double actualResult = calc.Divide(div1, div2); Assert.IsNull(actualResult, "Result does not have value"); }
public static void IsNull(object obj, string message = null) { #if XUNIT XUnitAssert.Null(obj); #else NUnitAssert.IsNull(obj, message); #endif }
public void TestUnpackNull_Stream_Nil_AsIs() { using (var buffer = new MemoryStream(new byte[] { 0xC0 })) { var result = Unpacking.UnpackNull(buffer); Assert.AreEqual(1, buffer.Position); Assert.IsNull(result); } }
public void SettingResultClearsException() { invocation.Exception = exception; invocation.Result = result; Assert.AreSame(result, invocation.Result, "should store result"); Assert.IsFalse(invocation.IsThrowing, "should not be throwing"); Assert.IsNull(invocation.Exception, "should not store an exception"); }
public void RemoveValueFromCache() { HttpSessionStateBase session = mocks.HtmlHelper.ViewContext.HttpContext.Session; session.AddValueToSession("key1", 1); Assert.AreEqual(1, session.GetValueFromSession <int>("key1")); session.ClearFromSession("key1"); Assert.IsNull(session.GetValueFromSession <int>("key1")); }