public void CanGetLatestVersion() { RegistryPackageVersion version = TestFactory.RegVer("1.0.0"); RegistryPackage package = TestFactory.RegScript("script1", version); var registry = TestFactory.Reg(package); var success = registry.TryGetPackageVersion(RegistryPackageType.Scripts, "script1", null, out var context); Assert.That(success, Is.True); Assert.That(context.Registry, Is.SameAs(registry)); Assert.That(context.Package, Is.SameAs(package)); Assert.That(context.Version, Is.SameAs(version)); }
public async Task GetPrivateAddressBooks_ReturnsAPrivateAddressBooksResponse() { // Arrange var client = TestFactory.CreateDotMailerCoreClient(); // Act var response = await client.GetPrivateAddressBooksAsync(); // Assert var model = Assert.IsAssignableFrom <List <AddressBook> >(response); Assert.True(model.Where(x => x.Visibility == AddressBookVisibility.Private).Count() == model.Count()); }
private IEnumerable <InputConfiguration> InputConfigs() { var c1 = TestFactory.CreateTestInputConfiguration(); var c2 = TestFactory.CreateTestInputConfiguration(); c1.Name = "c1"; c2.Name = "c2"; return(new List <InputConfiguration> { c1, c2 }); }
public void Test_Expired_Returns_False_When_Expiry_Date_Is_In_Future() { /// Arrange var token = TestFactory.Token(1); token.ExpiryDate = DateTime.Now.AddHours(5); // Act var expired = token.Expired; // Assert Assert.False(expired); }
public void Test_Expired_Returns_True_When_Expiry_Date_Has_Passed() { /// Arrange var token = TestFactory.Token(1); token.ExpiryDate = DateTime.Now.AddHours(-5); // Act var expired = token.Expired; // Assert Assert.True(expired); }
public void DisposePassesThroughOnlyOnce() { var factory = new TestFactory(); factory.ChannelMessageStream.Expect(s => s.Dispose()).Repeat.Once(); var reader = factory.Create(); reader.Dispose(); reader.Dispose(); factory.VerifyAllExpectations(); }
public void A_consumer_is_being_tested() { _test = TestFactory.ForConsumer <TwoMessageConsumer>() .New(x => { x.UseConsumerFactory(() => new TwoMessageConsumer()); x.Send(new A(), (scenario, context) => context.ResponseAddress = scenario.Bus.Address); x.Send(new B(), (scenario, context) => context.ResponseAddress = scenario.Bus.Address); }); _test.Execute(); }
internal HtmlTestDescriptor([NotNull] TestDescriptor testDescriptor) { Assert.ArgumentNotNull(testDescriptor, nameof(testDescriptor)); TestFactory testFactory = Assert.NotNull(TestDescriptorUtils.GetTestFactory(testDescriptor)); Name = testDescriptor.Name; Description = StringUtils.IsNotEmpty(testDescriptor.Description) ? testDescriptor.Description : null; TestDescription = testFactory.GetTestDescription(); Signature = TestImplementationUtils.GetTestSignature(testFactory); Type testType; if (testDescriptor.TestClass != null) { testType = testDescriptor.TestClass.GetInstanceType(); ConstructorId = testDescriptor.TestConstructorId; UsesConstructor = true; IsObsolete = TestDescriptorUtils.IsObsolete(testType, ConstructorId, out _obsoleteMessage); } else if (testDescriptor.TestFactoryDescriptor != null) { testType = testDescriptor.TestFactoryDescriptor.GetInstanceType(); ConstructorId = -1; UsesConstructor = false; IsObsolete = ReflectionUtils.IsObsolete(testType, out _obsoleteMessage); } else { throw new ArgumentException("Invalid test descriptor"); } AssemblyName = Path.GetFileName(testType.Assembly.Location); ClassName = testType.FullName; _issueCodes = IssueCodeUtils.GetIssueCodes(testType).ToList(); _testCategories = testFactory.TestCategories.OrderBy(c => c).ToList(); foreach (TestParameter testParameter in testFactory.Parameters) { var htmlTestParameter = new HtmlTestParameter(testParameter); _parameters.Add(htmlTestParameter); _testParametersByName.Add(testParameter.Name, htmlTestParameter); } }
public async Task DownloadMultiple_Returns_BadRequest_When_DriveItemIdIsNull() { // Arrange var documentLibraryId = SettingsHelper.DocumentLibraryId; var body = "{\"driveItems\": [null]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var logger = TestFactory.CreateLogger(LoggerTypes.List); // Act var httpActionResult = await _sut.DownloadMultiple(reqMock.Object, documentLibraryId, logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task DownloadMultiple_Returns_BadRequest_When_DocumentLibraryIdIsEmpty() { // Arrange var body = "{\"driveItems\": [\"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\", \"01EIR2WX4I7ZPREEQDMZG3SNTMBTLFBTID\"]}"; var reqMock = TestFactory.CreateHttpRequestMock(body); var documentLibraryId = string.Empty; // Act var httpActionResult = await _sut.DownloadMultiple(reqMock.Object, documentLibraryId, _logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public async Task Download_Returns_File_When_Found() { // Arrange var req = TestFactory.CreateHttpRequest(); var documentLibraryId = SettingsHelper.DocumentLibraryId; var driveItemId = SettingsHelper.DriveItemId; // Act var httpActionResult = await _sut.Download(req, documentLibraryId, driveItemId, _logger); // Assert Assert.IsInstanceOf(typeof(FileContentResult), httpActionResult); }
public async Task Download_Returns_BadRequest_When_DriveItemIdIsEmpty() { // Arrange var documentLibraryId = SettingsHelper.DocumentLibraryId; var driveItemId = string.Empty; var req = TestFactory.CreateHttpRequest(); // Act var httpActionResult = await _sut.Download(req, documentLibraryId, driveItemId, _logger); // Assert Assert.IsInstanceOf(typeof(BadRequestObjectResult), httpActionResult); }
public void IActionConstraintFactory_InitializesCorrectValues() { // Arrange var constraint = new TestFactory(); // Act var constraintValues = new ActionConstraintValues(constraint); // Assert Assert.False(constraintValues.IsConstraint); Assert.True(constraintValues.IsFactory); Assert.Equal(0, constraintValues.Order); Assert.Equal(typeof(TestFactory), constraintValues.ActionConstraintMetadataType); }
public void Begin() { if (Selection != null && Selection.IsDeckComplete()) { var deck = Selection.GetDeckList(); SL.Get <GameSessionData>().PlayerDeck = deck; SL.Get <GameSessionData>().EnemyDeck = TestFactory.GetDefaultEnemyDeck(); SceneManager.LoadScene("ClashScene"); } else { // TODO: Tell the player to select the right number of cards. } }
public void Test() { var action = TestFactory.CreateTestInputAction(); var container = InputActionExecutionContainer.Wrap(action); cmd = new ExecuteInputAction(actionProcessor, container); cmd.Execute().Wait(1000); var result = cmd.Result; Assert.IsNotNull(result); Assert.IsTrue(result.Success); actionProcessorMock.Verify(a => a.Process(), Times.Once); }
public async Task Timer_should_log_message() { var genericComponentsImportService = new Mock <IGenericComponentsImportService>(); genericComponentsImportService.Setup(x => x.SaveGenericNoiseComponents()).Returns(Task.FromResult((true, true))); Application.Function function = new Application.Function(genericComponentsImportService.Object); var loggerMocked = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); await function.Run(null, loggerMocked); var msg = loggerMocked.Logs[0]; Assert.Contains("C# Timer trigger function executed at", msg); }
public void Should_UpdateSingleDataSource() { var model = TestFactory.Create <InfluxDataSource>(); var res = _repo.Create(model); Assert.False(res.HasError); Assert.True(res.Value.Equals(model)); TestFactory.Update(( ModelInfluxDataSource )model); res = GetRepo <DataSourceRepository>().Update(model); Assert.False(res.HasError); Assert.True(res.Value.Equals(model)); }
public async Task AddCampaignAttachment_ReturnsAnAttachmentResponse() { // Arrange var campaignId = TestFactory.GetCampaignId(); var attatchment = TestFactory.GetCampaignAttatchment(); var mockRestResponse = TestFactory.CreateMockRestResponse <Attachment>(Constants.CampaignAddCampaignAttatchmentContent); var client = TestFactory.CreateDotMailerCoreClientWithResponse <Attachment>(mockRestResponse.Object); // Act var response = await client.AddCampaignAttachmentAsync(campaignId, attatchment); // Assert var model = Assert.IsAssignableFrom <Attachment>(response); }
public async Task GetPublicAddressBooks_ReturnsAPublicAddressBooksResponse() { // Arrange var mockRestResponse = TestFactory.CreateMockRestResponse <List <AddressBook> >(Constants.AddressBooksPublicContent); var client = TestFactory.CreateDotMailerCoreClientWithResponse <List <AddressBook> >(mockRestResponse.Object); // Act var response = await client.GetPublicAddressBooksAsync(); // Assert var model = Assert.IsAssignableFrom <List <AddressBook> >(response); Assert.True(model.Where(x => x.Visibility == AddressBookVisibility.Public).Count() == model.Count()); }
public void ShouldNot_UpdateDashboard_WhenNullInput() { var res = _repo.Update(null); Assert.True(res.HasError); Assert.True(res.Error.Code == ErrorCode.BadUpdateDashboard); var dashboard = TestFactory.Create <ModelDashboard>(); res = _repo.Update(dashboard); Assert.True(res.HasError); Assert.True(res.Error.Code == ErrorCode.BadGetDashboard); }
public void Parser_Throws_Exceptions(string format) { // Let's set the "ErrorAction" to "Throw": var formatter = Smart.CreateDefaultSmartFormat(new SmartSettings { Parser = new ParserSettings { ErrorAction = ParseErrorAction.ThrowError } }); var args = new object[] { TestFactory.GetPerson() }; Assert.Throws <ParsingErrors>(() => formatter.Test(format, args, "Error")); }
public async Task CopyCampaign_ReturnsACampaignResponse() { // Arrange var client = TestFactory.CreateDotMailerCoreClient(); var campaign = TestFactory.GetCampaign(); // Act var response = await client.UpdateCampaignAsync(campaign); // Assert var model = Assert.IsAssignableFrom <Campaign>(response); Equals(model.Id, campaign.Id); }
public void GetNegativeMessage_should_log_message() { // Arrange var logger = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); MessageFunction messageFunction = new MessageFunction(_messageResponderServer.Object); // Act messageFunction.GetNegativeMessage(null, logger); // Assert var msg = logger.Logs[0]; msg.Should().Contain("MessageFunction - C# HTTP trigger function processed a request for GetNegativeMessage."); }
public void Init() { packageManager = TestFactory.CreatePackageManager(); installDir = TestCommon.GetRandomTestDir(); // Create composite package catalog source var options = TestFactory.CreateCreateCompositePackageCatalogOptions(); var testSource = packageManager.GetPackageCatalogByName(Constants.TestSourceName); Assert.NotNull(testSource, $"{Constants.TestSourceName} cannot be null"); options.Catalogs.Add(testSource); options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs; compositeSource = packageManager.CreateCompositePackageCatalog(options); }
public async Task RemoveCampaignAttachment_ReturnsAnErrorResponse() { // Arrange var campaignId = TestFactory.GetCampaignId(); var campaignAttatchmentId = TestFactory.GetCampaignAttatchmentId(); var client = TestFactory.CreateDotMailerCoreClient(); // Act var ex = await Assert.ThrowsAsync <ApiException>(() => client.RemoveCampaignAttachmentAsync(campaignId, campaignAttatchmentId)); // Assert Assert.Equal((int)HttpStatusCode.Forbidden, ex.HttpStatus); Assert.Contains("ERROR_FEATURENOTACTIVE", ex.ResponseContent); }
public async Task ImportElectionResults_UpdatesRepo() { var sp = new ElectionResultsDataParser(_loggerFactory.Object); _repo.Setup(m => m.ImportElectionResultsData(It.IsAny <ElectionSummary>())) .Callback <ElectionSummary>(summary => { }); var data = TestFactory.GetTestSummaryDataStream(); await GetService(summaryParser : sp).ImportElectionResults(data); _repo.Verify(r => r.ImportElectionResultsData(It.IsAny <ElectionSummary>()), Times.Once); }
public void Should_UpdateMultipleDataSources() { var models = CreateDataContext().AddDataSources(5); foreach (var m in models) { TestFactory.Update(( ModelInfluxDataSource )m); var res = GetRepo <DataSourceRepository>().Update(m); Assert.False(res.HasError); Assert.True(res.Value.Equals(m)); } }
public ValidateApiController() { //TODO Initalize from constructor _dataRepository = new DbRepositoryContext(); _connectionFactory = new ConnectionFactory(_dataRepository.ConnectionRepository, _dataRepository.ConnectionProviderRepository); _testFactory = new TestFactory(_dataRepository.TestRepository, _dataRepository.TestTypeRepository, _dataRepository.ExpectedResultRepository, _dataRepository.AssertTypeRepository); _projectFactory = new ProjectFactory(_dataRepository.ProjectRepository, _dataRepository.TestRepository, _dataRepository.TestGroupRepository, _testFactory); _testGroupFactory = new TestGroupFactory(_dataRepository.TestRepository, _dataRepository.TestGroupRepository, _testFactory); }
public void Test_CarSelection2() { //http://en.wikipedia.org/wiki/Analytic_hierarchy_process_%E2%80%94_Car_example //https://rpubs.com/gluc/ahp IDecision tmp_project = TestFactory.ComplexCarSelectionProblem(); System.Diagnostics.Debug.WriteLine(tmp_project.ToString()); AnpSolver tmp_solver = new AnpSolver(tmp_project); IDecisionResult decisionResult = tmp_solver.Solve(); Assert.IsNotNull(decisionResult, "success"); }
public void ScaleToScreenTest() { TestFactory.CreateBaseServices(null, null, out IGridState gridState, out IDataDrawState graphState, out IItemFormatter itemFormatter, out IMargin margin, out IDataService dataService, out IScaleService scaleService); double x = new DateTime(1985, 6, 23).Ticks / TimeSpan.TicksPerMillisecond; Assert.IsTrue(scaleService.ScaleToScreen(Axis.X, 0) == 0); Assert.IsTrue(scaleService.ScaleToScreen(Axis.X, x) == x * scaleService.State.ScaleX); Assert.IsTrue(scaleService.ScaleToScreen(Axis.Y, 0) == 0); Assert.IsTrue(scaleService.ScaleToScreen(Axis.Y, .5) == .5 * scaleService.State.ScaleY); }
static void Main(string[] args) { // Console.WriteLine(BitConverter.IsLittleEndian); //ServicePointManager.DefaultConnectionLimit = 1000; TestFactory testFactory = new TestFactory("testSection"); testFactory.Run(); while (true) { Console.Clear(); foreach (IntegrationTest.TestCase item in testFactory.Cases) { Console.WriteLine(item); } System.Threading.Thread.Sleep(990); } Console.Read(); }
public SateliteTest() { IToolsFactory factory = new TestFactory(); constantes = new Constantes(factory); var resolver = new OrbitalContractResolver(); resolver.Ignore(typeof(Vector), "Magnitude"); resolver.Ignore(typeof(SateliteData), "SemiejeMayor"); resolver.Ignore(typeof(SateliteData), "Altura"); resolver.Ignore(typeof(SateliteData), "VelocidadPeriapsis"); jsonSettings = new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, FloatParseHandling = FloatParseHandling.Decimal, ContractResolver = resolver }; jsonSettings.Converters.Add(new VectorConverter()); jsonSettings.Converters.Add(new SateliteDataConverter(constantes)); }
/// <summary> /// /// </summary> /// <returns></returns> public bool ReadProject() { bool blnResult = false; ProjectFactory = null; ProjectFolder = null; ProjectList = null; ProjectFolder = FindFolder(Framework.ActiveApplication.QCTestPlan); if (ProjectFolder != null) { ProjectFactory = (TestFactory)ProjectFolder.TestFactory; if (ProjectFactory != null) { TDFilter filter = (TDFilter)ProjectFactory.Filter; filter["TS_NAME"] = "Process_template"; ProjectList = ProjectFactory.NewList(filter.Text); if (ProjectList.Count >= 1) { foreach (object item in ProjectList) { if (item is Test) { ProcessTemplate = item as Test; blnResult = true; break; } } } else { Message = "Cannnot find Process_Template in '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan."; } } else { Message = "Cannot determine project factory '" + Framework.ActiveProcess.QCTestPlan + "'."; } } else { Message = "Cannot find Project folder '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan.'"; } return blnResult; }
/// <summary> /// /// </summary> /// <returns></returns> public bool ResetProcess() { bool blnResult = false; ProcessFactory = null; ProcessFolder = FindFolder(Framework.ActiveProcess.QCTestPlan); if (ProcessFolder != null) { try { ProcessFactory = (TestFactory)ProcessFolder.TestFactory; } catch (Exception ex) { Message = "Could not set Process Factory '" + Framework.ActiveProcess.QCTestPlan + "' in ALM.\n" + ex.Message; } if (ProcessFactory != null) { ProcessList = ProcessFactory.NewList(""); ProcessIndex = 1; ProcessMax = ProcessList.Count; blnResult = true; } } else { Message = "Cannot find Process folder '" + Framework.ActiveProcess.QCTestPlan + "' in ALM Testplan'"; } return blnResult; }