예제 #1
0
        public void SearchLocationCommand_ServiceReternExceptionWithServerErrorResponseModel_ReternErrorMessage(string message, string code)
        {
            //Arrange
            var serverErrorResponse = new ServerErrorResponseModel
            {
                Message = message,
                Code    = code
            };

            string space = " ";

            _locationSearchServiceMoc
            .Setup(service => service.GetLocationListByTextAsync(It.IsAny <string>()))
            .ThrowsAsync(new ApiException(serverErrorResponse));

            var searchLocationListViewModel = new SearchLocationListViewModel(_locationSearchServiceMoc.Object);

            //Act
            searchLocationListViewModel.SearchLocationCommand.Execute(null);

            //Assert
            Assert.AreEqual($"{serverErrorResponse.Code}{space}{serverErrorResponse.Message}", searchLocationListViewModel.ErrorMessage);
            Assert.IsTrue(searchLocationListViewModel.IsErrorMessageVisible);
            Assert.IsFalse(searchLocationListViewModel.IsListVisible);
        }
        public void Fork_NewStamp_NotIsLeaf()
        {
            var target   = new Stamp();
            var newStamp = target.Fork();

            Assert.IsFalse(newStamp.Id.IsLeaf);
        }
예제 #3
0
        public ITestProperty AssertSetObjectIsValid(ITestObject testObject)
        {
            AssertIsVisible();
            AssertIsModifiable();
            ResetLastMessage();

            Assert.IsFalse(field.ReturnSpec.IsParseable, "Drop(..) not allowed on value target field; use SetValue(..) instead");
            INakedObjectAdapter testNakedObjectAdapter = testObject.NakedObject;

            Assert.IsTrue(testNakedObjectAdapter.Spec.IsOfType(field.ReturnSpec), string.Format("Can't drop a {0} on to the {1} field (which accepts {2})", testObject.NakedObject.Spec.ShortName, Name, field.ReturnSpec));
            INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject;
            IConsent            valid;
            var spec = field as IOneToOneAssociationSpec;

            if (spec != null)
            {
                valid = spec.IsAssociationValid(nakedObjectAdapter, testNakedObjectAdapter);
            }
            else if (field is IOneToManyAssociationSpec)
            {
                valid = new Veto("Always disabled");
            }
            else
            {
                throw new UnknownTypeException(field);
            }
            LastMessage = valid.Reason;

            Assert.IsFalse(valid.IsVetoed, string.Format("Cannot SetObject {0} in the field {1} within {2}: {3}", testNakedObjectAdapter, field, nakedObjectAdapter, valid.Reason));
            return(this);
        }
예제 #4
0
        public void DebugPythonProjectWithAndWithoutClearingPythonPath()
        {
            var    origPythonPath = Environment.GetEnvironmentVariable("PYTHONPATH");
            string testDataPath   = TestData.GetPath("TestData\\HelloWorld").Replace("\\", "\\\\");

            Environment.SetEnvironmentVariable("PYTHONPATH", testDataPath);
            try {
                using (var app = new VisualStudioApp()) {
                    app.OpenProject(TestData.GetPath(@"TestData\SysPath.sln"));

                    app.ServiceProvider.GetPythonToolsService().GeneralOptions.ClearGlobalPythonPath = false;
                    try {
                        ClearOutputWindowDebugPaneText();
                        app.Dte.ExecuteCommand("Debug.Start");
                        WaitForMode(app, dbgDebugMode.dbgDesignMode);

                        WaitForDebugOutput(text => text.Contains(testDataPath));
                    } finally {
                        app.ServiceProvider.GetPythonToolsService().GeneralOptions.ClearGlobalPythonPath = true;
                    }

                    ClearOutputWindowDebugPaneText();
                    app.Dte.ExecuteCommand("Debug.Start");
                    WaitForMode(app, dbgDebugMode.dbgDesignMode);

                    WaitForDebugOutput(text => text.Contains("DONE"));
                    var outputWindowText = GetOutputWindowDebugPaneText();
                    Assert.IsFalse(outputWindowText.Contains(testDataPath), outputWindowText);
                }
            } finally {
                Environment.SetEnvironmentVariable("PYTHONPATH", origPythonPath);
            }
        }
 public void ShouldShowOtherServicesServiceTypeDescription_GoToGPOHH_FromOtherServices_ReturnsFalse()
 {
     _recommendedServiceViewModel.ServiceTypeDescription = "Service descritpion";
     _recommendedServiceViewModel.ServiceType.Id         = 25;
     _recommendedServiceViewModel.OnlineDOSServiceType   = OnlineDOSServiceType.GoTo;
     Assert.IsFalse(_recommendedServiceViewModel.ShouldShowOtherServicesServiceTypeDescription(true));
 }
 public void ShouldShowOtherServicesServiceTypeDescription_GoToOther_FromRecommendedService_ReturnsFalse()
 {
     _recommendedServiceViewModel.ServiceTypeDescription = "Service descritpion";
     _recommendedServiceViewModel.ServiceType.Id         = 100;
     _recommendedServiceViewModel.OnlineDOSServiceType   = OnlineDOSServiceType.GoTo;
     Assert.IsFalse(_recommendedServiceViewModel.ShouldShowOtherServicesServiceTypeDescription(false));
 }
 public void ShouldShowOtherServicesServiceTypeDescription_PhoneCAS_FromOtherServices_ReturnsFalse()
 {
     _recommendedServiceViewModel.ServiceTypeDescription = "Service descritpion";
     _recommendedServiceViewModel.ServiceType.Id         = 130;
     _recommendedServiceViewModel.OnlineDOSServiceType   = OnlineDOSServiceType.PublicPhone;
     Assert.IsFalse(_recommendedServiceViewModel.ShouldShowOtherServicesServiceTypeDescription(true));
 }
 public void ShouldShowOtherServicesServiceTypeDescription_PhoneGPOHH_FromRecommendedService_ReturnsFalse()
 {
     _recommendedServiceViewModel.ServiceTypeDescription = "Service descritpion";
     _recommendedServiceViewModel.ServiceType.Id         = 25;
     _recommendedServiceViewModel.OnlineDOSServiceType   = OnlineDOSServiceType.PublicPhone;
     Assert.IsFalse(_recommendedServiceViewModel.ShouldShowOtherServicesServiceTypeDescription(false));
 }
 public void ShouldShowServiceTypeDescription_GoToCAS_ReturnsFalse()
 {
     _recommendedServiceViewModel.ServiceTypeDescription = "Service descritpion";
     _recommendedServiceViewModel.ServiceType.Id         = 130;
     _recommendedServiceViewModel.OnlineDOSServiceType   = OnlineDOSServiceType.GoTo;
     Assert.IsFalse(_recommendedServiceViewModel.ShouldShowServiceTypeDescription());
 }
    public void False()
    {
        bool myBool = true;

        // MSTest
        MSTestAssert.IsFalse(myBool, "Some context");
        // Assert.IsFalse failed. Some context

        // NUnit
        Assert.That(myBool, Is.False, () => "Some context");
        // Some context
        //  Expected: False
        //  But was: True

        // XUnit
        XUnitAssert.False(myBool, "User message");
        // User message
        // Expected: False
        // Actual:  True

        // Fluent
        myBool.Should().BeFalse("SOME REASONS");
        // Expected myBool to be false because SOME REASONS, but found True.

        // Shouldly
        myBool.ShouldBeFalse("Some context");
        // myBool
        //   should be
        // False
        //   but was
        // True
        //
        // Additional Info:
        //  Some context
    }
예제 #11
0
        public void Test()
        {
            var obj = new object();

            Assert.IsTrue(SingletonTester.IsSingleton(() => obj));
            Assert.IsFalse(SingletonTester.IsSingleton(() => new object()));
        }
예제 #12
0
        public ITestProperty AssertIsInvisible()
        {
            bool canAccess = field.IsVisible(owningObject.NakedObject);

            Assert.IsFalse(canAccess, "Field '" + Name + "' is visible");
            return(this);
        }
예제 #13
0
        public void Check_Between()
        {
            var check = Validator.CheckValue(1, "One")
                        .EqualsTo(1)
                        .BetweenInclusive(-1, 1)
                        .BetweenInclusive(1, 2)
                        .Between(0, 2);

            XAssert.IsFalse(Validator.HasErrors);

            check.Between(1, 2);
            XAssert.AreEqual(check.Error["Min"], 1);
            XAssert.AreEqual(check.Error["Max"], 2);
            XAssert.AreEqual(check.Error["Value"], 1);
            XAssert.AreEqual(check.Error["Validator"], "Between");

            check.Between(0, 1);
            XAssert.AreEqual(check.Error["Min"], 0);
            XAssert.AreEqual(check.Error["Max"], 1);
            XAssert.AreEqual(check.Error["Value"], 1);
            XAssert.AreEqual(check.Error["Validator"], "Between");

            check.BetweenInclusive(-1, 0);
            XAssert.AreEqual(check.Error["Min"], -1);
            XAssert.AreEqual(check.Error["Max"], 0);
            XAssert.AreEqual(check.Error["Value"], 1);
            XAssert.AreEqual(check.Error["Validator"], "BetweenInclusive");

            check.BetweenInclusive(2, 3);
            XAssert.AreEqual(check.Error["Min"], 2);
            XAssert.AreEqual(check.Error["Max"], 3);
            XAssert.AreEqual(check.Error["Value"], 1);
            XAssert.AreEqual(check.Error["Validator"], "BetweenInclusive");
        }
예제 #14
0
 public void StringUtils_ContainsTest()
 {
     Assert.IsFalse(contains1);
     Assert.IsFalse(contains2);
     Assert.IsTrue(contains3);
     Assert.IsFalse(contains4);
 }
        public void EqualsTest()
        {
            IDictionary <string, JobParameter> myJobP = new Dictionary <string, JobParameter>
            {
                { "p1", new JobParameter("param1") },
                { "p2", new JobParameter(2) },
                { "p3", new JobParameter(3.0) },
                { "p4", new JobParameter(DateTime.Parse("1970-07-31")) }
            };

            JobParameters jp = new JobParameters(myJobP);

            //NOTE : ORDER DOES NOT COUNT ON EQUALS COMPARISON, ONLY <KEY,VALUES>
            //SAME BEHAVIOUR AS LinkedHashMap
            IDictionary <string, JobParameter> myJobP2 = new Dictionary <string, JobParameter>
            {
                { "p2", new JobParameter(2) },
                { "p1", new JobParameter("param1") },
                { "p3", new JobParameter(3.0) },
                { "p4", new JobParameter(DateTime.Parse("1970-07-31")) }
            };

            JobParameters jp2 = new JobParameters(myJobP2);
            JobParameters jp3 = new JobParameters();

            Assert.IsTrue(DictionaryUtils <string, JobParameter> .AreEqual(myJobP, myJobP2));
            Assert.IsTrue(jp.Equals(jp2));
            Assert.IsFalse(jp.Equals(jp3));
        }
        public void Test04After30MinutesCanNotAddABookInTheCart()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient   = application.Login("marcos", "123");
            Guid   aCartId   = application.CreateCart(aClient.Id, aClient.Password);
            string aBook     = objectProvider.ABook();
            string otherBook = objectProvider.OtherBook();


            application.AddAQuantityOfAnItem(1, aBook, aCartId);
            application.Clock.UpdateSomeMinutes(30); // minutes

            try
            {
                application.AddAQuantityOfAnItem(1, otherBook, aCartId);
                Assert.Fail();
            }
            catch (TimeoutException e)
            {
                Assert.AreEqual("The cart has been expired", e.Message);

                Cart aCart = application.GetCart(aCartId);
                Assert.IsFalse(aCart.HasABook(otherBook));
            }
        }
예제 #17
0
        public void StringUtils_IsNumberTest()
        {
            Assert.IsTrue(isdouble1);
            Assert.IsTrue(isdouble2);
            Assert.IsTrue(isdouble3);
            Assert.IsTrue(isdouble4);
            Assert.IsTrue(isdouble5);
            Assert.IsTrue(isdouble6);
            Assert.IsTrue(isdouble7);
            Assert.IsTrue(isdouble8);
            Assert.IsTrue(isdouble9);
            Assert.IsTrue(isdouble10);
            Assert.IsFalse(isdouble11);
            Assert.IsFalse(isdouble12);
            Assert.IsFalse(isdouble13);
            Assert.IsFalse(isdouble14);
            Assert.IsFalse(isdouble15);

            Assert.IsTrue(isinteger1);
            Assert.IsFalse(isinteger2);
            Assert.IsTrue(isinteger3);
            Assert.IsFalse(isinteger4);
            Assert.IsTrue(isinteger5);
            Assert.IsFalse(isinteger6);
            Assert.IsFalse(isinteger7);
            Assert.IsFalse(isinteger8);
            Assert.IsTrue(isinteger9);
            Assert.IsFalse(isinteger10);
            Assert.IsFalse(isinteger11);
            Assert.IsFalse(isinteger12);
            Assert.IsFalse(isinteger13);
            Assert.IsFalse(isinteger14);
            Assert.IsFalse(isinteger15);
        }
예제 #18
0
        public void Floorplan_TotalOverlap_OccludesNeighbour()
        {
            //Left and right rooms are close enough to be considered neighbours
            var roomLeft  = _plan.Add(new Vector2[] { new Vector2(-100, -20), new Vector2(-100, 20), new Vector2(-0.45f, 20), new Vector2(-0.45f, -20) }, 1f).Single();
            var roomRight = _plan.Add(new Vector2[] { new Vector2(100, 20), new Vector2(100, -20), new Vector2(0.45f, -20), new Vector2(0.45f, 20) }, 1f).Single();

            //This room squeezes between them, occluding their neighbour relationship
            var roomMid = _plan.Add(new Vector2[] { new Vector2(20, 40), new Vector2(20, -40), new Vector2(-20, -40), new Vector2(-20, 40) }, 0.1f).Single();

            _plan.Freeze();
            DrawPlan();

            //Check left/right borders only mid
            Assert.IsTrue(roomLeft.Neighbours.All(a => a.RoomCD.Equals(roomMid)));
            Assert.IsTrue(roomRight.Neighbours.All(a => a.RoomCD.Equals(roomMid)));
            //Check mid borders both left and right
            Assert.IsTrue(roomMid.Neighbours.Any(a => a.RoomCD.Equals(roomRight)) && roomMid.Neighbours.Any(a => a.RoomCD.Equals(roomLeft)));

            //Check that left does not neighbour right
            Assert.IsFalse(roomLeft.Neighbours.Any(a => a.RoomCD == roomRight));

            //Check all neighbour data is correctly wound
            AssertAllWindings();

            //Check all sections lies on the external footprint of the involved rooms
            AssertAllSections();
        }
        public void GetConflictingItems_ChangesHaveNoConflicts_NoConflictsInSyncResult()
        {
            // Create non conflicting items
            Guid id          = Guid.NewGuid();
            var  serverStamp = new Stamp();
            var  clientStamp = serverStamp.Fork();
            var  serverItem  = new TestItem {
                Id = id, Stamp = serverStamp
            };
            var clientItem = new TestItem {
                Id = id, Stamp = clientStamp
            };

            // Arrange server repository to return server item
            var repository = Mocking.MockAndBind <IRepository <TestItem, Guid> >(_container);

            Mock.Arrange(() => repository.Find(id)).Returns(serverItem);

            // Arrange client sync request
            ISyncRequest <Guid> syncRequest = new SyncRequest <TestItem, Guid> {
                new SyncItem <Guid>(clientItem)
            };

            var target = new SyncResult <TestItem, Guid>(_container);

            target.GetConflictingItems(syncRequest);

            Assert.IsFalse(target.ConflictingItems.Contains(serverItem));
        }
예제 #20
0
        public void TestAutoMapperDi()
        {
            var mapper = DiServiceBuilder.GetService <IMapper>();
            var result = mapper.Map <string>("Жопа");

            Assert.IsFalse(string.IsNullOrEmpty(result));
        }
예제 #21
0
        public void AttemptingToRetrieveNewFilmsWhenDbIsDownGivesAppropriateResponse()
        {
            _mockFilmContext.BreakPersistence();
            ActionResult <ResponseObject <Film> > actualResponse = _testFilmController.GetNewFilms();

            Assert.IsFalse(actualResponse.Value.successful);
        }
예제 #22
0
        public void ShowNextPreviousMonthYear_NextMonth_AddTdAttributeAndNotImg()
        {
            // Arrange:
            var calendar = new Mock <Calendar>();

            calendar.Object.ID           = DummyCalendarId;
            calendar.Object.ClientIDMode = ClientIDMode.Static;
            calendar.SetupGet(x => x.ImagesDirectory).Returns(DummyImageDirectory);

            var output = new HtmlTextWriter(new StringWriter());

            output.RenderBeginTag(HtmlTextWriterTag.Div);
            var argumentForRefParameter = new object[] { CalendarNextPreviousType.NextMonth, output };
            var privateObject           = new PrivateObject(calendar.Object, new PrivateType(typeof(Calendar)));

            // Act:
            privateObject.Invoke("ShowNextPreviousMonthYear", argumentForRefParameter);
            output.RenderEndTag();

            // Assert:
            var outputTextWriter = argumentForRefParameter[1] as HtmlTextWriter;

            Assert.IsTrue(outputTextWriter.InnerWriter.ToString().Contains("<div>"));
            Assert.IsTrue(outputTextWriter.InnerWriter.ToString().Contains("<td"));
            Assert.IsFalse(outputTextWriter.InnerWriter.ToString().Contains("<img"));
        }
예제 #23
0
        public ITestProperty SetValue(string textEntry)
        {
            AssertIsVisible();
            AssertIsModifiable();
            ResetLastMessage();

            INakedObjectAdapter nakedObjectAdapter = owningObject.NakedObject;

            try {
                field.GetNakedObject(nakedObjectAdapter);

                var parseableFacet = field.ReturnSpec.GetFacet <IParseableFacet>();

                INakedObjectAdapter newValue = parseableFacet.ParseTextEntry(textEntry, manager);

                IConsent consent = ((IOneToOneAssociationSpec)field).IsAssociationValid(nakedObjectAdapter, newValue);
                LastMessage = consent.Reason;

                Assert.IsFalse(consent.IsVetoed, string.Format("Content: '{0}' is not valid. Reason: {1}", textEntry, consent.Reason));

                ((IOneToOneAssociationSpec)field).SetAssociation(nakedObjectAdapter, textEntry.Trim().Equals("") ? null : newValue);
            }
            catch (InvalidEntryException) {
                Assert.Fail("Entry not recognised " + textEntry);
            }
            return(this);
        }
예제 #24
0
        public void TestGet()
        {
            var user = new User();

            var name = Option.Safe(() => user.GetSchool().District.Street.Name);

            Assert.IsFalse(name.ValidChain());
        }
예제 #25
0
        public void TestBasicNullWithValueTypeTarget()
        {
            var user = new User();

            var name = Option.Safe(() => user.School.District.Street.Number);

            Assert.IsFalse(name.ValidChain());
        }
예제 #26
0
        public void TestWithValueTypeTargetNullField()
        {
            User user = null;

            var name = Option.Safe(() => user.Field.Field.Field.Field.Field);

            Assert.IsFalse(name.ValidChain());
        }
예제 #27
0
        public void TestIsEaster()
        {
            DateTime dtR = new DateTime(2011, 4, 24);
            DateTime dtW = new DateTime(2011, 4, 25);

            Assert.IsTrue(dtR.IsEaster());
            Assert.IsFalse(dtW.IsEaster());
        }
예제 #28
0
        public void Nulls()
        {
            Validator.CheckValue((string)null).IsAbsoluteUri();
            XAssert.IsFalse(Validator.IsValid);

            Validator.CheckValue((Uri)null).IsAbsoluteUri();
            XAssert.IsFalse(Validator.IsValid);
        }
        public void ConnectNoTestCases()
        {
            // execute
            var testCases = new TextConnector(new RhinoConfiguration(), Utilities.Types).ProviderManager.TestRun.TestCases;

            // assert
            Assert.IsFalse(testCases.Any());
        }
예제 #30
0
            public void IsPalindromeShouldReturnFalse()
            {
                this.Iban.SetIBAN("RO41RZBR1764567821546321");

                bool result = this.Iban.IsPalindrome();

                Assert.IsFalse(result);
            }