public void Activate_SetsPropertiesFromActionContextHierarchy() { // Arrange var httpRequest = Mock.Of<HttpRequest>(); var httpContext = new Mock<HttpContext>(); httpContext.SetupGet(c => c.Request) .Returns(httpRequest); httpContext.SetupGet(c => c.RequestServices) .Returns(Mock.Of<IServiceProvider>()); var routeContext = new RouteContext(httpContext.Object); var controller = new TestController(); var context = new ActionContext(routeContext, new ActionDescriptor()) { Controller = controller }; var activator = new DefaultControllerActivator(); // Act activator.Activate(controller, context); // Assert Assert.Same(context, controller.ActionContext); Assert.Same(httpContext.Object, controller.HttpContext); Assert.Same(httpRequest, controller.GetHttpRequest()); }
public void Changes_should_not_be_submitted_if_there_are_errors_in_modelstate() { var controller = new TestController(); controller.ModelState.AddModelError("foo", "bar"); filter.OnActionExecuted(new ActionExecutedContext() { Controller = controller }); context.ChangesSubmitted.ShouldBeFalse(); }
public void Transaction_should_be_commited_when_action_completes() { var controller = new TestController(); filter.OnActionExecuting(new ActionExecutingContext { Controller = controller }); filter.OnActionExecuted(new ActionExecutedContext { Controller = controller }); transaction.AssertWasCalled(t => t.Commit()); }
public void Activate_PopulatesServicesFromServiceContainer() { // Arrange var urlHelper = Mock.Of<IUrlHelper>(); var service = new Mock<IServiceProvider>(); service.Setup(s => s.GetService(typeof(IUrlHelper))) .Returns(urlHelper); var httpContext = new Mock<HttpContext>(); httpContext.SetupGet(c => c.RequestServices) .Returns(service.Object); var routeContext = new RouteContext(httpContext.Object); var controller = new TestController(); var context = new ActionContext(routeContext, new ActionDescriptor()) { Controller = controller }; var activator = new DefaultControllerActivator(); // Act activator.Activate(controller, context); // Assert Assert.Same(urlHelper, controller.Helper); }
public ConferenceTenantControllerFixture() { this.routes = new RouteCollection(); this.routeData = new RouteData(); this.routeData.Values.Add("controller", "Test"); this.routeData.Values.Add("conferenceCode", "demo"); var requestMock = new Mock<HttpRequestBase>(MockBehavior.Strict); requestMock.SetupGet(x => x.ApplicationPath).Returns("/"); requestMock.SetupGet(x => x.Url).Returns(new Uri("http://localhost/request", UriKind.Absolute)); requestMock.SetupGet(x => x.ServerVariables).Returns(new NameValueCollection()); requestMock.Setup(x => x.ValidateInput()); var responseMock = new Mock<HttpResponseBase>(MockBehavior.Strict); responseMock.Setup(x => x.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s); var context = Mock.Of<HttpContextBase>(c => c.Request == requestMock.Object && c.Response == responseMock.Object); this.dao = new Mock<IConferenceDao>(); this.sut = new TestController(this.dao.Object); this.sut.ControllerContext = new ControllerContext(context, this.routeData, this.sut); this.sut.Url = new UrlHelper(new RequestContext(context, this.routeData), this.routes); }
static void Main(string[] args) { ResponsivenessSingleton.GetInstance().Initialize(); TestView view = new TestView(); TestController controller = new TestController( new ConsoleResponsiveHelper(ConcurrencyMode.Modal), view); controller.DoWork(); }
public void HandleResultWithNullResult() { // Setup var controller = new TestController(); // Execute _mvc.HandleResult(a_controller: controller, a_result: null); }
public void derived_controller_should_return_not_implemented() { var testController = new TestController(); request.HttpMethod = "Get"; testController.Get(request).Content.ShouldBe("TestController.Get: Not Implemented."); }
public void HeadShouldSendHeadersSetInGetMethod() { var controller = new TestController().WithStubbedContext(); controller.Head("test"); Assert.That(controller.Response.Headers["Cache-Control"], Is.EqualTo("public")); }
public void JsonAcceptTypeShouldReturnJson() { _controller = TestControllerBuilder.TestController().WithAcceptTypes(new[] {"application/json"}).Build(); ActionResult result = _controller.Index(); result.ShouldBeType<ReSTCore.ActionResults.JsonResult>(); }
public void HtmlAcceptTypeShouldReturnHtml() { _controller = TestControllerBuilder.TestController().WithAcceptTypes(new[] { "text/html" }).Build(); ActionResult result = _controller.Index(); result.ShouldBeType<ViewResult>(); }
public void MethodNotSupportedShouldReturn405() { var controller = new TestController().WithStubbedContext(); controller.MethodNotSupported("test"); Assert.That(controller.Response.StatusCode, Is.EqualTo(405)); }
public void Transaction_should_be_rolled_back_if_there_are_errors_in_modelstate() { var controller = new TestController(); controller.ModelState.AddModelError("foo", "bar"); filter.OnActionExecuting(new ActionExecutingContext { Controller = controller }); filter.OnActionExecuted(new ActionExecutedContext { Controller = controller }); transaction.AssertWasCalled(t => t.Rollback()); }
public void TestIsController() { TestController controller = new TestController(); NotTestController notController = new NotTestController(); Assert.IsTrue(Helpers.Controllers.IsController(controller.GetType())); Assert.IsFalse(Helpers.Controllers.IsController(notController.GetType())); }
public void Can_Parse_Signal_Response() { var testController = new TestController(); var result = testController.TestSignal(testSessionId); Assert.NotNull(result); Assert.AreEqual(result, "QUEUED"); }
public void GivenIControllerType_WhenICreateController_ThenContructTheType() { RequestContext request = new RequestContext(MockHttpContextFactory.Create(), new RouteData()); IController expected = new TestController(); Type controllerType = expected.GetType(); Kernel.Expect(m => m.Resolve(controllerType)).Return(expected); IController actual = Target.ExecuteGetControllerInstance(request, controllerType); Assert.AreEqual(expected, actual); }
public void Setup() { _container = MockRepository.GenerateStub<IContainer>(); _routeData = new RouteData(); _requestContext = new RequestContext(MockRepository.GenerateStub<HttpContextBase>(), _routeData); _testController = new TestController(); _structureMapControllerFactory = new StructureMapControllerFactory(_container); }
public void HeadShouldSetContentLengthHeaderButClearBody() { var controller = new TestController().WithStubbedContext(); controller.Head("test"); Assert.That(controller.Response.Headers["Content-Length"], Is.EqualTo("hello".Length.ToString())); Assert.That(controller.Response.Output.ToString(), Is.EqualTo("")); }
public void EstablishContext() { testTreeModel = MockRepository.GenerateStub<ITestTreeModel>(); optionsController = MockRepository.GenerateStub<IOptionsController>(); eventAggregator = MockRepository.GenerateStub<IEventAggregator>(); filterService = MockRepository.GenerateStub<IFilterService>(); testController = new TestController(testTreeModel, optionsController, new TestTaskManager(), eventAggregator, filterService); }
public void Index_WithNoError_ReturnsDefaultView() { var controller = new TestController(); ViewResult result = controller.Index(); Assert.IsNotNull(result); Assert.IsTrue(String.IsNullOrEmpty(result.ViewName)); }
public void Can_Create_Signal_Url() { var testController = new TestController(); var url = testController.TestSignalTo(testSessionId); var expectedUrl = string.Format(TestController.TropoSignalTemplate, testApiToken, testSessionId, Event.Continue); Assert.NotNull(url); Assert.AreEqual(expectedUrl, url); }
public static ActionExecutingContext CreateActionExecutingContext() { var controller = new TestController(); ActionDescriptor actionDescriptor = CreateActionDescriptorFor(controller, "TestAction"); var routeData = new RouteData(); var httpContext = MockRepository.GenerateStub<HttpContextBase>(); var controllerContext = new ControllerContext(httpContext, routeData, controller); return new ActionExecutingContext(controllerContext, actionDescriptor, new Dictionary<string, object>()); }
public void OnPropertyChanged_without_synchronization_context() { var testController = new TestController(); bool propertyChangedFlag = false; testController.PropertyChanged += delegate { propertyChangedFlag = true; }; testController.Notify("test"); Assert.AreEqual(false, propertyChangedFlag); }
public void should_return_next_route() { var c = new TestController(); var route = "action test".ToRoute(); var result = c.Execute(route); result.Resource.ShouldBe("test"); result.Action.ShouldBe("success"); }
public void AlsoExecute_Should_Be_Added() { var r=new Router(); var controller=new TestController(new RequestContext(null, r, null, null)); var ctrl=r.Controller(x=>controller); bool calledexecute=false; ctrl.Handles("/foo").With(x=>x.Test()).AlsoExecute(c=>calledexecute=true); bool skip=false; ctrl.Current.Responder(null, ref skip); Assert.IsTrue(calledexecute); }
public void RenderView_Should_Get_Calling_Function_Name_As_View() { var webPage = new MockGet(new string[] { "Test", "List" }); var controller = new TestController(); Mvc.Run(webPage, controller); Assert.AreEqual("~/Views//__List.cshtml", webPage.Page.View); webPage.Verify(); }
public void Setup() { var container = new MockContainer(); container.Register(typeof (ITestService), typeof (TestService)); IoC.SetImplementation(container); _controller = new TestController(); var route = "action test".ToRoute(); _result = _controller.Execute(route); }
public void ExceptionShouldBeWrittenToHeader() { const string error = "oh my, an exception!"; _controller = TestControllerBuilder.TestController().Build(); var context = new ExceptionContext { Exception = new Exception(error) }; _controller.ThrowException(context); _controller.Headers.Get(Constants.Headers.ErrorMessage).ShouldEqual(error); }
public virtual void Setup() { Bus = MockRepository.GenerateStub<IBus>(); TestController = new TestController(); Container = MockRepository.GenerateStub<IContainer>(); TestCommandMessage = MockRepository.GenerateStub<ITestCommandMessage>(); Bus.Stub(bus => bus.CreateInstance<ITestCommandMessage>()).Return(TestCommandMessage); CommandBus = new CommandBus(Bus, Container); }
public void HeadShouldChangeRouteAction() { // For example, the Representation class depends on the route action, and would // fail if called under the context of a HEAD call var controller = new TestController().WithStubbedContext() .WithRouteValue("action", "Head"); controller.Head("test"); Assert.That(controller.RouteData.Values["action"], Is.EqualTo("Index")); }
public void CreateControllerFactory_UsesControllerActivatorAndPropertyActivator() { // Arrange var expectedProperty1 = new object(); var expectedProperty2 = new object(); var expectedController = new TestController(); var factory = new DefaultControllerFactory( Mock.Of <IControllerActivator>(), Enumerable.Empty <IControllerPropertyActivator>()); var activatorProvider = new Mock <IControllerActivatorProvider>(); activatorProvider.Setup(p => p.CreateActivator(It.IsAny <ControllerActionDescriptor>())) .Returns(_ => expectedController) .Verifiable(); var propertyActivator1 = new Mock <IControllerPropertyActivator>(); propertyActivator1.Setup(p => p.GetActivatorDelegate(It.IsAny <ControllerActionDescriptor>())) .Returns((context, controllerObject) => { ((TestController)controllerObject).ActivatedValue1 = expectedProperty1; }) .Verifiable(); var propertyActivator2 = new Mock <IControllerPropertyActivator>(); propertyActivator2.Setup(p => p.GetActivatorDelegate(It.IsAny <ControllerActionDescriptor>())) .Returns((context, controllerObject) => { ((TestController)controllerObject).ActivatedValue2 = expectedProperty2; }) .Verifiable(); var propertyActivators = new[] { propertyActivator1.Object, propertyActivator2.Object, }; var provider = new ControllerFactoryProvider( activatorProvider.Object, factory, propertyActivators); var descriptor = new ControllerActionDescriptor { ControllerTypeInfo = typeof(TestController).GetTypeInfo(), }; // Act var factoryDelegate = provider.CreateControllerFactory(descriptor); var controller = factoryDelegate(new ControllerContext()); // Assert var actual = Assert.IsType <TestController>(controller); Assert.Same(expectedController, actual); Assert.Same(expectedProperty1, actual.ActivatedValue1); Assert.Same(expectedProperty2, actual.ActivatedValue2); activatorProvider.Verify(); propertyActivator1.Verify(); propertyActivator2.Verify(); }
protected override ControllerAction GetActionUsingUrl(TestController testController) { return(testController.Action("ActionUsingUrl")); }
/// <summary> /// Initializes a new instance of the <see cref="ChromelyControllerTest"/> class. /// </summary> /// <param name="testOutput"> /// The test output. /// </param> public ChromelyControllerTest(ITestOutputHelper testOutput) { mTestOutput = testOutput; mTestController = new TestController(); }
private TestController CreateController(AspNetCore.Http.HttpRequest request) { TestController controller = new TestController(); return(controller); }
protected override void Run() { try { mDebugger.Send("Run"); // C# WhileLoopTests.Execute(); ForeachLoopTests.Execute(); // System ObjectTests.Execute(); ArrayTests.Execute(); StringTest.Execute(); ByteTest.Execute(); SByteTest.Execute(); Int16Test.Execute(); UInt16Test.Execute(); Int32Test.Execute(); UInt32Test.Execute(); Int64Test.Execute(); UInt64Test.Execute(); CharTest.Execute(); BooleanTest.Execute(); SingleTest.Execute(); DoubleTest.Execute(); MathTest.Execute(); ConvertTests.Execute(); DateTimeTests.Execute(); TimeSpanTests.Execute(); //mDebugger.Send("Thread test start of 500 ms"); //ThreadTest.Execute(); //mDebugger.Send("Thread test end"); //DecimalTest.Execute(); BitConverterTest.Execute(); UnsafeCodeTest.Execute(); DelegatesTest.Execute(); RandomTests.Execute(); // System.Collections HashtableTest.Execute(); // System.Collections.Generic ListTest.Execute(); QueueTest.Execute(); DictionaryTest.Execute(); // System.Text StringBuilderTest.Execute(); EncodingTest.Execute(); TestController.Completed(); } catch (Exception e) { mDebugger.Send("Exception occurred: " + e.Message); mDebugger.Send(e.Message); Console.WriteLine("Exception occurred"); Console.WriteLine(e.Message); TestController.Failed(); } }
void Start() { _controller = Controller.GetComponent <TestController>(); }
public override void StateUpdate(Animator animator) { TestController.ReportStateUpdate(stateName); }
protected override void Run() { try { mDebugger.Send("Run"); object xString = "a"; string xString2 = "b"; Assert.IsTrue(xString.GetType() == typeof(string), "GetType or typeof() works for reference types!"); Assert.IsTrue(xString.GetType() == xString2.GetType(), "GetType or typeof() works for reference types!"); Assert.IsTrue(xString is ICloneable, "isinst works for interfaces on reference types!"); Assert.IsTrue(xString is IEnumerable <char>, "isinst works for generic interfaces on reference types!"); Assert.IsFalse(xString.GetType().IsValueType, "IsValueType works for reference types!"); IComparable <int> xNumber = 3; Assert.IsTrue(xNumber.GetType() == typeof(int), "GetType or typeof() works for value types!"); Assert.IsTrue(xNumber is IConvertible, "isinst works for interfaces on value types!"); Assert.IsTrue(xNumber is IEquatable <int>, "isinst works for generic interfaces on value types!"); IEnumerable <string> xEnumerable = new List <string>(); Assert.IsTrue(xEnumerable.GetType() == typeof(List <string>), "GetType or typeof() works for reference types!"); Assert.IsTrue(xEnumerable is global::System.Collections.IEnumerable, "isinst works for interfaces on generic reference types!"); Assert.IsTrue(xEnumerable is IList <string>, "isinst works for generic interfaces on generic reference types!"); B b = new B(); Assert.IsTrue(b.GetType() == typeof(B), "GetType or typeof() works for custom types!"); Type baseType = b.GetType().BaseType; Type objectType = typeof(A); Assert.IsTrue(baseType == objectType, "BaseType works for custom reference types!"); Assert.IsTrue(b.GetType().BaseType == new B().GetType().BaseType, "BaseType works for custom reference types!"); Assert.IsTrue(b.GetType().IsSubclassOf(typeof(A)), "IsSubClassOf works for custom reference types!"); byte xByte = 1; Assert.IsTrue(xByte.GetType() == typeof(byte), "GetType or typeof() works for value types!"); Assert.IsTrue(xByte.GetType().IsSubclassOf(typeof(ValueType)), "IsSubClassOf works for value types!"); Assert.IsTrue(xByte.GetType().IsValueType, "IsValueType works for value types!"); Action a = () => { }; Action <int> a1 = (i) => test++; Assert.IsTrue(a != null, "Anonymous type for action is created correctly"); Assert.IsTrue(a1 != null, "Anonymous type for action<int> is created correctly"); var c = new { i = 1, n = "Test" }; Assert.IsTrue(c != null, "Anonymous types are created correctly"); Assert.IsTrue(c.i == 1 && c.n == "Test", "Anonymous types have correct values"); TestVTablesImpl(); TestGarbageCollectorMethods(); TestGarbageCollector(); RealMethodsTest(); TestController.Completed(); } catch (Exception e) { mDebugger.Send("Exception occurred: " + e.Message); mDebugger.Send(e.Message); Console.WriteLine("Exception occurred"); Console.WriteLine(e.Message); TestController.Failed(); } }
public override void StateMachineExit(Animator animator) { TestController.ReportStateMachineExit(stateName); }
protected override void Run() { TestSHA1(); TestController.Completed(); }
public void Construct( TestController gameController) { _gameController = gameController; }
public async Task BindActionArgumentsAsync_SetsMultipleControllerProperties() { // Arrange var boundPropertyTypes = new Dictionary <string, Type> { { nameof(TestController.ArrayProperty), typeof(string[]) }, // Skipped { nameof(TestController.CollectionProperty), typeof(List <string>) }, { nameof(TestController.NonCollectionProperty), typeof(Person) }, // Skipped { nameof(TestController.NullCollectionProperty), typeof(List <string>) }, // Skipped { nameof(TestController.StringProperty), typeof(string) }, }; var inputPropertyValues = new Dictionary <string, object> { { nameof(TestController.ArrayProperty), new string[] { "hello", "world" } }, { nameof(TestController.CollectionProperty), new List <string> { "hello", "world" } }, { nameof(TestController.NonCollectionProperty), new Person { Name = "Fred" } }, { nameof(TestController.NullCollectionProperty), new List <string> { "hello", "world" } }, { nameof(TestController.StringProperty), "Hello" }, }; var expectedPropertyValues = new Dictionary <string, object> { { nameof(TestController.ArrayProperty), new string[] { "goodbye" } }, { nameof(TestController.CollectionProperty), new List <string> { "hello", "world" } }, { nameof(TestController.NonCollectionProperty), new Person { Name = "Ginger" } }, { nameof(TestController.NullCollectionProperty), null }, { nameof(TestController.StringProperty), "Hello" }, }; var actionDescriptor = GetActionDescriptor(); foreach (var keyValuePair in boundPropertyTypes) { actionDescriptor.BoundProperties.Add( new ParameterDescriptor { Name = keyValuePair.Key, BindingInfo = new BindingInfo(), ParameterType = keyValuePair.Value, }); } var controllerContext = GetControllerContext(actionDescriptor); var binder = new StubModelBinder(bindingContext => { // BindingContext.ModelName will be string.Empty here. This is a 'fallback to empty prefix' // because the value providers have no data. object model; if (inputPropertyValues.TryGetValue(bindingContext.FieldName, out model)) { bindingContext.Result = ModelBindingResult.Success(bindingContext.ModelName, model); } else { bindingContext.Result = ModelBindingResult.Failed(bindingContext.ModelName); } }); var factory = GetModelBinderFactory(binder); controllerContext.ValueProviders.Add(new SimpleValueProvider()); var argumentBinder = GetArgumentBinder(factory); var controller = new TestController(); // Act var result = await argumentBinder.BindActionArgumentsAsync(controllerContext, controller); // Assert Assert.Equal(new string[] { "goodbye" }, controller.ArrayProperty); // Skipped Assert.Equal(new List <string> { "hello", "world" }, controller.CollectionProperty); Assert.Equal(new Person { Name = "Ginger" }, controller.NonCollectionProperty); // Skipped Assert.Null(controller.NullCollectionProperty); // Skipped Assert.Null(controller.UntouchedProperty); // Not bound Assert.Equal("Hello", controller.StringProperty); }
private static bool ThereIsInput(this TestController @this) { return(GetButton(@this.Keys[KeyNames.HorizontalKey]) || GetButton(@this.Keys[KeyNames.VerticalKey])); }
public void OnSwordButtonClicked(PointerEventData data) { TestController test = player.transform.GetComponent <TestController>(); test.Attack(true); }
public void Setup() { var mockedLogger = new Mock <ILogger <TestController> >(); _testControllerBase = new TestController(mockedLogger.Object); }
public async Task AirlockBlockTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes }; var server = StartServer(options); await server.WaitIdleAsync(); var mapManager = server.ResolveDependency <IMapManager>(); var entityManager = server.ResolveDependency <IEntityManager>(); IEntity physicsDummy = null; IEntity airlock = null; TestController controller = null; AirlockComponent airlockComponent = null; var physicsDummyStartingX = -1; server.Assert(() => { var mapId = new MapId(1); mapManager.CreateNewMapEntity(mapId); var humanCoordinates = new MapCoordinates((physicsDummyStartingX, 0), mapId); physicsDummy = entityManager.SpawnEntity("PhysicsDummy", humanCoordinates); airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId)); Assert.True(physicsDummy.TryGetComponent(out IPhysicsComponent physics)); controller = physics.EnsureController <TestController>(); Assert.True(airlock.TryGetComponent(out airlockComponent)); Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed)); }); await server.WaitIdleAsync(); // Push the human towards the airlock controller.LinearVelocity = (0.5f, 0); for (var i = 0; i < 240; i += 10) { // Keep the airlock awake so they collide airlock.GetComponent <IPhysicsComponent>().WakeBody(); // Ensure that it is still closed Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed)); await server.WaitRunTicks(10); await server.WaitIdleAsync(); } // Sanity check Assert.That(physicsDummy.Transform.MapPosition.X, Is.GreaterThan(physicsDummyStartingX)); // Blocked by the airlock Assert.That(physicsDummy.Transform.MapPosition.X, Is.Negative.Or.Zero); }
protected override void Run() { try { mDebugger.Send("Run"); /* A red Point */ Pen pen = new Pen(Color.Red); canvas.DrawPoint(pen, 69, 69); /* A GreenYellow horizontal line */ pen.Color = Color.GreenYellow; canvas.DrawLine(pen, 250, 100, 400, 100); /* An IndianRed vertical line */ pen.Color = Color.IndianRed; canvas.DrawLine(pen, 350, 150, 350, 250); /* A MintCream diagonal line */ pen.Color = Color.MintCream; canvas.DrawLine(pen, 250, 150, 400, 250); /* A PaleVioletRed rectangle */ pen.Color = Color.PaleVioletRed; canvas.DrawRectangle(pen, 350, 350, 80, 60); pen.Color = Color.Chartreuse; canvas.DrawCircle(pen, 69, 69, 10); pen.Color = Color.DimGray; canvas.DrawEllipse(pen, 100, 69, 10, 50); pen.Color = Color.MediumPurple; canvas.DrawPolygon(pen, new Point(200, 250), new Point(250, 300), new Point(220, 350), new Point(210, 275)); Console.ReadKey(); /* Let's try to change mode...*/ canvas.Mode = new Mode(800, 600, ColorDepth.ColorDepth32); //If the background is not redrawn, it gets corrupted (this happens more in VmWare) canvas.Clear(Color.Blue); /* A LimeGreen rectangle */ pen.Color = Color.LimeGreen; canvas.DrawRectangle(pen, 450, 450, 80, 60); /* A filled rectange */ pen.Color = Color.Chocolate; canvas.DrawFilledRectangle(pen, 200, 150, 400, 300); canvas.DrawImage(bitmap, new Point(0, 0)); Console.ReadKey(); TestController.Completed(); } catch (Exception e) { mDebugger.Send("Exception occurred: " + e.Message); mDebugger.Send(e.Message); TestController.Failed(); } }
private CreatedODataResult <T> GetCreatedODataResult <T>(T entity, HttpRequestMessage request, TestController controller = null) { if (controller != null) { return(new CreatedODataResult <T>(entity, controller)); } else { return(new CreatedODataResult <T>(entity, _contentNegotiator, request, _formatters, _locationHeader)); } }
public ServiceRouteProviderTest(ITestOutputHelper testOutput) { m_testOutput = testOutput; m_testController = new TestController(); }
protected override ControllerAction GetIndexAction(TestController testController) { return(testController.Action("index")); }
public void RunTestsButton_Clicked(object sender, EventArgs e) { GUIController.LogOutput("Running tests"); TestController.RunAllTests(); }
public void InitializeUnitOfWork() { tests = new List <Test>() { new Test() { ID = 1, Mark = 12, Name = "Math", Randomize = true, UserID = 1, SubjectID = 1, Groups = new List <Group>(), Results = new List <Result>() }, new Test() { ID = 2, Mark = 100, Name = "Programming", Randomize = false, UserID = 1, SubjectID = 2, Groups = new List <Group>(), Results = new List <Result>() }, new Test() { ID = 3, Mark = 50, Name = "History", Randomize = true, UserID = 2, SubjectID = 1, Groups = new List <Group>(), Results = new List <Result>() } }; subjects = new List <Subject>() { new Subject() { ID = 1, Name = "Math" }, new Subject() { ID = 2, Name = "Programming" } }; groups = new List <Group>() { new Group() { ID = 1, Name = "AMI-33", Tests = new List <Test>() { tests[0], tests[1] } }, new Group() { ID = 2, Name = "10-A", Tests = new List <Test>() { tests[2] } } }; currentUser = new User() { ID = 1, FirstName = "Test", LastName = "User", Login = "******", IsTeacher = true, Tests = tests.Where(t => t.UserID == 1).ToList(), Groups = new List <Group>() { groups[0] } }; tests[2].Groups.Add(groups[0]); mockRepository = new Mock <IGenericRepository <Test> >(); mockRepository.Setup(r => r.GetAll()).Returns(tests.AsQueryable()); mockRepository.Setup(r => r.GetByID(It.IsAny <int>())).Returns <int>(id => tests.FirstOrDefault(q => q.ID == id)); var mockUserRepo = new Mock <IGenericRepository <User> >(); mockUserRepo.Setup(r => r.GetByID(It.Is <int>(id => id == currentUser.ID))) .Returns <int>(id => currentUser); var mockSubjectRepo = new Mock <IGenericRepository <Subject> >(); mockSubjectRepo.Setup(r => r.GetAll()).Returns(subjects.AsQueryable()); var mockGroupRepo = new Mock <IGenericRepository <Group> >(); mockGroupRepo.Setup(r => r.GetAll()).Returns(groups.AsQueryable()); mockGroupRepo.Setup(r => r.GetByID(It.IsAny <int>())).Returns <int>(id => groups.FirstOrDefault(q => q.ID == id)); var mockUow = new Mock <IUnitOfWork>(); mockUow.Setup(u => u.Tests).Returns(mockRepository.Object); mockUow.Setup(u => u.Users).Returns(mockUserRepo.Object); mockUow.Setup(u => u.Subjects).Returns(mockSubjectRepo.Object); mockUow.Setup(u => u.Groups).Returns(mockGroupRepo.Object); mockUow.Setup(u => u.Save()).Callback(mockRepository.Object.Save); unitOfWrok = mockUow.Object; controller = new TestController(unitOfWrok); updateCurrentUser(); }
public void SetHider(TestController player) { this.player = player; }
protected override ControllerAction GetUpdateAction(TestController testController) { return(testController.Action("update")); }
private CreatedODataResult <T> GetCreatedODataResult <T>(T entity, HttpRequest request, TestController controller = null) { return(new CreatedODataResult <T>(entity)); }
protected override void Run() { Assert.IsTrue(TestBoxingCharToString(), "Boxing char to string test failed."); Assert.IsTrue(TestBoxingCharArrayToString(), "Boxing char[] to string test failed."); TestController.Completed(); }
protected override void Run() { /** * Packet creation and parsing tests **/ /** Ethernet Packet Parsing Test **/ byte[] ethernetPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00 }; EthernetPacket ethernetPacket = new EthernetPacket(ethernetPacketData); Equals(ethernetPacketData, ethernetPacket.RawData); /** IP Packet Parsing Test **/ byte[] ipPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x0C, 0x29, 0xD5, 0xDB, 0x9D, 0x08, 0x00, 0x45, 0x00, 0x01, 0x16, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, 0x39, 0xD8, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; IPPacket ipPacket = new IPPacket(ipPacketData); Equals(ipPacketData, ipPacket.RawData); /** UDP Packet Parsing Test **/ byte[] udpPacketData = new byte[] { 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0xD8, 0xCE, 0x3A, 0x89, 0x3E, 0xD9, 0x08, 0x00, 0x45, 0x00, 0x00, 0x22, 0x0C, 0x74, 0x40, 0x00, 0x40, 0x11, 0xAA, 0xBE, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8, 0x01, 0x46, 0x10, 0x92, 0x10, 0x92, 0x00, 0x0E, 0x37, 0x22, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x21 }; UDPPacket udpPacket = new UDPPacket(udpPacketData); Equals(udpPacketData, udpPacket.RawData); /** DNS Packet Parsing Test **/ byte[] dnsPacketData = new byte[] { 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x98, 0xFA, 0x9B, 0xD4, 0xEB, 0x29, 0x08, 0x00, 0x45, 0x00, 0x00, 0x38, 0xC3, 0x1C, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0xC0, 0xA8, 0x01, 0xFE, 0xF0, 0x66, 0x00, 0x35, 0x00, 0x24, 0x84, 0xCA, 0xD6, 0x80, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x69, 0x74, 0x74, 0x65, 0x72, 0x03, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x01, 0x00, 0x01 }; DNSPacket dnsPacket = new DNSPacket(dnsPacketData); Equals(dnsPacketData, dnsPacket.RawData); /** DHCP Packet Parsing Test **/ byte[] dhcpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x00, 0x45, 0xC0, 0x01, 0x59, 0x46, 0x3F, 0x00, 0x00, 0x40, 0x11, 0x6F, 0xEF, 0xC0, 0xA8, 0x01, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x43, 0x00, 0x44, 0x01, 0x45, 0xD3, 0xC8, 0x02, 0x01, 0x06, 0x00, 0x84, 0xA9, 0x5A, 0x66, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x47, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x34, 0xE1, 0x2D, 0xA3, 0x06, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, 0x53, 0x63, 0x35, 0x01, 0x05, 0x36, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x33, 0x04, 0x00, 0x01, 0x51, 0x80, 0x3A, 0x04, 0x00, 0x00, 0xA8, 0xC0, 0x3B, 0x04, 0x00, 0x01, 0x27, 0x50, 0x1C, 0x04, 0xC0, 0xA8, 0x01, 0xFF, 0x51, 0x12, 0x03, 0xFF, 0xFF, 0x44, 0x45, 0x53, 0x4B, 0x54, 0x4F, 0x50, 0x2D, 0x49, 0x51, 0x48, 0x4A, 0x33, 0x31, 0x43, 0x06, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x0F, 0x03, 0x6C, 0x61, 0x6E, 0x03, 0x04, 0xC0, 0xA8, 0x01, 0xFE, 0x01, 0x04, 0xFF, 0xFF, 0xFF, 0x00, 0xFF }; DHCPPacket dhcpPacket = new DHCPPacket(dhcpPacketData); Equals(dhcpPacketData, dhcpPacket.RawData); /** ARP Packet Parsing Test **/ byte[] arpPacketData = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xB8, 0xD9, 0x4D, 0xC1, 0xA5, 0xFC, 0xC0, 0xA8, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; ARPPacket arpPacket = new ARPPacket(arpPacketData); Equals(arpPacketData, arpPacket.RawData); TestController.Completed(); /** * Clients tests **/ var dhcpCLient = new DHCPClient(); dhcpCLient.Close(); var dnsClient = new DnsClient(); dnsClient.Close(); var udpClient = new UdpClient(); udpClient.Close(); var icmpClient = new ICMPClient(); icmpClient.Close(); }
protected override ControllerAction GetChildAction(TestController testController) { return(testController.Action("ChildPartialViewAction")); }
public static void Main() { { var test = new TestController(); test.TestExitLoop(); test.TestPlayState(); test.TestStop(); test.TestPause(); test.TestDefaultValues(); test.TestVolume(); test.TestIsLooped(); test.TestPlay(); } { var test = new TestAudioSystem(); test.TestDopplerCoherency(); test.TestAttenuationCoherency(); test.TestLocalizationCoherency(); test.TestSeveralControllers(); test.TestEffectsAndMusic(); test.TestAddRemoveEmitter(); test.TestRemoveListener(); test.TestAddListener(); test.TestAudioEngine(); test.TestAddRemoveListener(); } { var test = new TestAudioEmitterProcessor(); test.TestEmitterUpdateValues(); test.TestAddRemoveListeners(); test.TestAddRemoveEntityWithEmitter(); test.TestAddRemoveSoundEffect(); } // { // var test = new TestAudioEmitterComponent(); // test.TestInitialization(); // test.TestAttachDetachSounds(); // test.TestGetController(); // } { var test = new TestAudioListenerProcessor(); test.TestAddAudioSysThenEntitySys(); test.TestAddEntitySysThenAudioSys(); test.TestRemoveListenerFromAudioSystem(); test.TestRemoveListenerFromEntitySystem(); } { var test = new TestGame(); test.TestAccessToAudio(); test.TestCreationDestructionOfTheGame(); } { var test = new TestScriptContext(); test.TestScriptCreationDestruction(); test.TestScriptAudioAccess(); } { var test = new TestAssetLoading(); test.TestSoundEffectLoading(); test.TestSoundMusicLoading(); } }
protected override void Run() { try { mDebugger.Send("Run"); string xContents; Assert.IsTrue(Path.GetDirectoryName(@"0:\test") == @"0:\", @"Path.GetDirectoryName(@'0:\test') == @'0:\'"); Assert.IsTrue(Path.GetFileName(@"0:\test") == @"test", @"Path.GetFileName(@'0:\test') == @'test'"); bool xTest; //mDebugger.Send("File exist check:"); //xTest = File.Exists(@"0:\Kudzu.txt"); //Assert.IsTrue(xTest, @"\Kudzu.txt not found!"); //mDebugger.Send("Directory exist check:"); //xTest = Directory.Exists(@"0:\test"); //Console.WriteLine("After test"); //Assert.IsTrue(xTest, "Folder does not exist!"); //mDebugger.Send("File contents of Kudzu.txt: "); //xContents = File.ReadAllText(@"0:\Kudzu.txt"); //mDebugger.Send("Contents retrieved"); //mDebugger.Send(xContents); //Assert.IsTrue(xContents == "Hello Cosmos", "Contents of Kudzu.txt was read incorrectly!"); using (var xFS = new FileStream(@"0:\Kudzu.txt", FileMode.Open)) { xFS.SetLength(5); } mDebugger.Send("File made smaller"); xContents = File.ReadAllText(@"0:\Kudzu.txt"); mDebugger.Send("Contents retrieved"); mDebugger.Send(xContents); Assert.IsTrue(xContents == "Hello", "Contents of Kudzu.txt was read incorrectly!"); //using (var xFS = new FileStream(@"0:\Kudzu.txt", FileMode.Create)) //{ // mDebugger.Send("Start writing"); // var xStr = "Test FAT Write."; // var xBuff = xStr.GetUtf8Bytes(0, (uint) xStr.Length); // xFS.Write(xBuff, 0, xBuff.Length); // mDebugger.Send("---- Data written"); // xFS.Position = 0; // xFS.Read(xBuff, 0, xBuff.Length); // mDebugger.Send(xBuff.GetUtf8String(0, (uint)xBuff.Length)); //} //mDebugger.Send("Write to file now"); //File.WriteAllText(@"0:\Kudzu.txt", "Test FAT write."); //mDebugger.Send("Text written"); //xContents = File.ReadAllText(@"0:\Kudzu.txt"); //mDebugger.Send("Contents retrieved after writing"); //mDebugger.Send(xContents); //Assert.IsTrue(xContents == "Test FAT write.", "Contents of Kudzu.txt was written incorrectly!"); TestController.Completed(); } catch (Exception E) { mDebugger.Send("Exception occurred"); mDebugger.Send(E.Message); TestController.Failed(); } }