protected void Initialize() { Assembly startupAssembly = typeof(TStartup).GetTypeInfo().Assembly; string relativePath = Path.Combine(""); string contentRoot = TestProjectHelper.GetProjectPath(relativePath, startupAssembly); IConfigurationBuilder configurationBuilder = new ConfigurationBuilder() .SetBasePath(contentRoot) .AddJsonFile(ConfigurationFileName); IConfiguration configuration = configurationBuilder.Build(); IWebHostBuilder webHostBuilder = new WebHostBuilder() .UseContentRoot(contentRoot) .ConfigureServices(services => InitializeServices(services, configuration)) .UseConfiguration(configuration) .UseEnvironment(EnvironmentName) .UseStartup(typeof(TStartup)); m_server = new TestServer(webHostBuilder); Client = m_server.CreateClient(); Client.BaseAddress = new Uri("https://localhost:5001"); Client.DefaultRequestHeaders.Accept.Clear(); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
public void Init() { base.InitBase(); project = new MockCSharpProject(); context.MockUnitTestsPad.AddProject(project); string[] methodNames = new string[] { "FirstTest", "SecondTest", "ThirdTest" }; testProject = TestProjectHelper.CreateTestProjectWithTestClassTestMethods(project, "MyTests.MyTestClass", methodNames); TestClass testClass = testProject.TestClasses[0]; firstTestMethod = testClass.TestMethods[0]; secondTestMethod = testClass.TestMethods[1]; thirdTestMethod = testClass.TestMethods[2]; context.MockUnitTestsPad.AddTestProject(testProject); MockBuildProjectBeforeTestRun buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); context.UnitTestingOptions.NoThread = true; context.UnitTestingOptions.NoShadow = true; context.UnitTestingOptions.NoLogo = true; context.UnitTestingOptions.NoDots = true; context.UnitTestingOptions.Labels = true; context.UnitTestingOptions.CreateXmlOutputFile = true; testFramework = new MockTestFramework(); context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework); runTestCommand.Run(); buildProjectBeforeTestRun.FireBuildCompleteEvent(); errorTestResult = new TestResult("MyTests.MyTestClass.FirstTest"); errorTestResult.ResultType = TestResultType.Failure; warningTestResult = new TestResult("MyTests.MyTestClass.SecondTest"); warningTestResult.ResultType = TestResultType.Ignored; successTestResult = new TestResult("MyTests.MyTestClass.ThirdTest"); successTestResult.ResultType = TestResultType.Success; context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true; MockTestRunner testRunner = runTestCommand.TestRunnersCreated[0]; testRunner.FireTestFinishedEvent(errorTestResult); testRunner.FireTestFinishedEvent(warningTestResult); testRunner.FireTestFinishedEvent(successTestResult); context.MockUnitTestsPad.IsUpdateToolbarMethodCalled = false; runningTestsBeforeTestsFinishedCalled = AbstractRunTestCommand.IsRunningTest; runTestCommand.CallTestsCompleted(); }
public void Init() { base.InitBase(); project1 = new MockCSharpProject(); testProject1 = TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass1", "testMethod1"); project2 = new MockCSharpProject(); testProject2 = TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass2", "testMethod2"); context.MockUnitTestsPad.AddProject(project1); context.MockUnitTestsPad.AddProject(project2); context.MockUnitTestsPad.AddTestProject(testProject1); context.MockUnitTestsPad.AddTestProject(testProject2); buildProject1 = new MockBuildProjectBeforeTestRun(); context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject1); runTestCommand.Run(); buildProject1.FireBuildCompleteEvent(); runTestCommand.CallTestsCompleted(); }
public void Init() { string[] methods = new string[] { "Foo", "Bar" }; testProject = TestProjectHelper.CreateTestProjectWithTestClassTestMethods("MyClass", methods); testClass = testProject.TestClasses[0]; }
public void Init() { testProject = TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod("MyNamespace.MyClass", "MyTestMethod"); if (testProject.TestClasses.Count > 0) { testClass = testProject.TestClasses[0]; if (testClass.TestMethods.Count > 0) { testMethod = testClass.TestMethods[0]; } } }
public void Init() { string className = "MyNamespace.MyTests"; TestProject testProject = TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(className, "MyTestMethod"); TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod"); testResult.ResultType = TestResultType.Ignored; testResult.Message = "Test ignored"; task = TestResultTask.Create(testResult, testProject); }
public async Task SingIn_ValidUsed_SignInSuccessResponse() { //Arrange string email = "*****@*****.**"; string password = "******"; string route = "auth/signin"; SignInRequest request = new SignInRequest(email, password); //Act HttpResponseMessage response = await m_client .PostAsync(route, TestProjectHelper.GetStringContent(request)); string content = await response.Content.ReadAsStringAsync(); JwtAuthResult authResult = JsonConvert.DeserializeObject <JwtAuthResult>(content); //Assert response.EnsureSuccessStatusCode(); Assert.NotNull(authResult); }