IEnumerator Begin() { yield return(new WaitForSeconds(1)); factory = FindObjectOfType <SampleFactory>(); bottleneckUI = FindObjectOfType <BottleneckUI>(); factory.RunTest = false; timer = waitTimeBeforeSwitch; ap = Holder.Instance; if (ap == null || !ap.Active) { state = "Adaptive Performance not active"; Debug.Log("[AP Bottleneck] Adaptive Performance not active"); FinishTest(); } else { timeOuttimer = timeOut; watch.Start(); factory.prefab = cpuLoader; factory.RunTest = true; state = "Ramping up CPU load"; StartCoroutine(ObserveBottleneck()); markers.Add(new Marker { label = state, time = watch.ElapsedMilliseconds, objectCount = factory.internalObjs }); Debug.Log("[AP Bottleneck] Starting Test"); } bottleneckStatus.text = state; }
protected override int Execute(DateTime when) { int result; PostAssetRequest sampleLoad = SampleFactory.BuildLoad(when); // build a search request based on the load to be posted CreateSearchRequest searchRequest = SampleFactory.BuildSearch(sampleLoad); SessionFacade session1; SessionFacade session2; if (Account1FailsLogin(out session1) || Account2FailsLogin(out session2)) { result = Result.Invalid; } else { session1.Post(sampleLoad); session2.Search(searchRequest); result = Result.Success; } return(result); }
public static void Main(string[] args) { SampleFactory factory = new SampleFactory(); using (BookContext db = factory.CreateDbContext(null)) { Book book1 = new Book(3, "Funny stories", "Stories", new DateTime(2020, 10, 2), 100); Book book2 = new Book(4, "Dandelion wine", "Stories", new DateTime(2020, 9, 30), 200); // добавляем их в бд db.AddBook(book1); db.AddBook(book2); db.SaveChanges(); Console.WriteLine("Объекты успешно сохранены"); // получаем объекты из бд и выводим на консоль var books = db.GetBooks().GetAwaiter().GetResult(); Console.WriteLine("Список объектов:"); foreach (Book b in books) { Console.WriteLine($"{b.Id}.{b.Name} - {b.Genre}"); } } }
public void When_I_update_an_AHC_bank_account_Then_it_should_be_updated_sync() { _profile = _service.Create(_profile); var address = SampleFactory.CreateSampleAddress(_profile); address = _service.Create(address); AchBankAccounts account = SampleFactory.CreatSampleAchBankAccount(_profile, address); account = _service.Create(account); var newAccountHolderName = "Foo"; account.AccountHolderName(newAccountHolderName); _service.Update(account); var returnedAccount = _service.Get(AchBankAccounts.Builder() .Id(account.Id()) .ProfileId(_profile.Id()) .Build()); Assert.That(returnedAccount.AccountHolderName(), Is.EqualTo(newAccountHolderName)); _service.Delete(account); }
public void When_I_process_a_payment_using_a_payment_token_Then_it_should_return_a_valid_response_sync() { var cardService = SampleFactory.CreateSampleCardPaymentService(); var vaultService = SampleFactory.CreateSampleCustomerVaultService(); var profile = SampleFactory.CreateSampleProfile(); profile = vaultService.Create(profile); var address = SampleFactory.CreateSampleAddress(profile); address = vaultService.Create(address); var card = SampleFactory.CreateSampleCard(profile, address); card = vaultService.Create(card); var response = cardService.Authorize(Authorization.Builder() .MerchantRefNum(Guid.NewGuid().ToString()) .Amount(555) .SettleWithAuth(false) .Card() .PaymentToken(card.PaymentToken()) .Done() .Build()); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public async Task When_I_update_an_EFT_bank_account_Then_it_should_be_updated_async() { _profile = await _service.CreateAsync(_profile); var address = SampleFactory.CreateSampleAddress(_profile); address = await _service.CreateAsync(address); EftBankAccounts account = SampleFactory.CreatSampleEftBankAccount(_profile, address); account = await _service.CreateAsync(account); var newAccountHolderName = "Foo"; account.AccountHolderName(newAccountHolderName); await _service.UpdateAsync(account); var returnedAccount = await _service.GetAsync(EftBankAccounts.Builder() .Id(account.Id()) .ProfileId(_profile.Id()) .BillingAddressId(address.Id()) .Build()); Assert.That(returnedAccount.AccountHolderName(), Is.EqualTo(newAccountHolderName)); await _service.DeleteAsync(account); }
public void ObjectGraphComparisonStrategyCommentSample() { var l1 = new Sample("SAmplE", null); var l2 = new Sample("1", l1); var l3 = new Sample("TeeST", l2); var l4 = new Sample("2", l3); l1.Child = l4; // l4 -> l3 -> l2 -> l1 -> l4 var r1 = new Sample("sample", null); var r2 = new Sample("1", r1); var r3 = new Sample("TeeeST", r2); var r4 = new Sample("2", r3); r1.Child = r4; var factory = new SampleFactory(); var graph1 = factory.CreateObjectGraph(l4); var graph2 = factory.CreateObjectGraph(r4); IEnumerable <ObjectComparisonMismatch> mismatches; var result = new ObjectGraphComparer().Compare(graph1, graph2, out mismatches); Assert.False(result); Assert.Equal(1, mismatches.Count()); var expected = "ObjectValuesDoNotMatch:Left=Sample.Sample(TeeST) Right=Sample.Sample(TeeeST)"; var actual = TestHelpers.StringFromMismatches(mismatches)[0]; Assert.Equal(expected, actual); }
public async Task When_I_verify_a_card_using_a_payment_token_Then_it_should_return_a_valid_response_async() { var cardService = SampleFactory.CreateSampleCardPaymentService(); var vaultService = SampleFactory.CreateSampleCustomerVaultService(); var profile = SampleFactory.CreateSampleProfile(); profile = await vaultService.CreateAsync(profile); var address = SampleFactory.CreateSampleAddress(profile); address = await vaultService.CreateAsync(address); var card = SampleFactory.CreateSampleCard(profile, address); card = await vaultService.CreateAsync(card); var response = await cardService.VerifyAsync(Verification.Builder() .MerchantRefNum(Guid.NewGuid().ToString()) .Card() .PaymentToken(card.PaymentToken()) .Done() .Build()); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void SampleFactoryTest() { SampleFactory sampleFactory = new SampleFactory(); IProduct product = sampleFactory.Create(Category.A); Assert.AreEqual(product.GetType(), typeof(ConcreteProductA)); }
public async Task When_I_process_an_ach_purchase_using_a_token_Then_it_should_return_a_valid_response_async() { var vaultService = SampleFactory.CreateSampleCustomerVaultService(); var profile = SampleFactory.CreateSampleProfile(); profile = await vaultService.CreateAsync(profile); var address = SampleFactory.CreateSampleAddress(profile); address = await vaultService.CreateAsync(address); var account = SampleFactory.CreatSampleEftBankAccount(profile, address); account = await vaultService.CreateAsync(account); Purchases response = await _achDirectDebitService.SubmitAsync(Purchases.Builder() .MerchantRefNum(System.Guid.NewGuid().ToString()) .Amount(10038) .Ach() .PaymentToken(account.PaymentToken()) .Done() .Build()); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void When_I_process_an_eft_standalone_using_a_payment_token_credit_Then_it_should_return_a_valid_response_sync() { var vaultService = SampleFactory.CreateSampleCustomerVaultService(); var profile = SampleFactory.CreateSampleProfile(); profile = vaultService.Create(profile); var address = SampleFactory.CreateSampleAddress(profile); address = vaultService.Create(address); var account = SampleFactory.CreatSampleEftBankAccount(profile, address); account = vaultService.Create(account); var response = _eftDirectDebitService.Submit(StandaloneCredits.Builder() .MerchantRefNum(account.MerchantRefNum()) .Amount(10038) .Eft() .PaymentToken(account.PaymentToken()) .Done() .Build()); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public async Task When_I_process_an_ach_standalone_using_a_payment_token_credit_Then_it_should_return_a_valid_response_async() { var vaultService = SampleFactory.CreateSampleCustomerVaultService(); var profile = SampleFactory.CreateSampleProfile(); profile = await vaultService.CreateAsync(profile); var address = SampleFactory.CreateSampleAddress(profile); address = await vaultService.CreateAsync(address); var account = SampleFactory.CreatSampleAchBankAccount(profile, address); account = await vaultService.CreateAsync(account); var response = await _achDirectDebitService.SubmitAsync(StandaloneCredits.Builder() .MerchantRefNum(account.MerchantRefNum()) .Amount(10038) .Ach() .PayMethod("WEB") .PaymentToken(account.PaymentToken()) .Done() .Build()); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public async Task When_I_process_a_complex_auth_Then_it_should_return_a_valid_response_async() { var complexAuth = SampleFactory.CreateSampleComplexAuthorization(); var response = await _cardService.AuthorizeAsync(complexAuth); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
static async Task Main(string[] args) { //Change the sample to execute below with the generic type await SampleFactory.Execute <GetPointFromCircle>(); Console.WriteLine("End!"); Console.ReadLine(); }
public static SampleFactory GetInstance() { if (_instance == null) { _instance = new SampleFactory(); } return(_instance); }
public void When_I_verify_a_card_payment_Then_it_should_return_a_valid_response_sync() { var ver = SampleFactory.CreateSampleVerification(); var response = _cardService.Verify(ver); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public static SampleFactory GetInstance() { if (_instance == null) { _instance = new SampleFactory(); } return _instance; }
public void BuildSample_Scalar_AsInDecoration() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.Scalar, Is.EqualTo('a')); }
public void When_I_process_a_valid_purchase_Then_it_should_return_a_valid_response_sync() { var settledAuth = SampleFactory.CreateSampleSettledAuthorization(); var response = _cardService.Authorize(settledAuth); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void BuildSample_UndecoratedType_Null() { var subject = new SampleFactory(); var @null = subject.BuildSample(typeof(string)); Assert.That(@null, Is.Null); }
public void BuildSample_DecoratedType_Instance() { var subject = new SampleFactory(); var notNull = subject.BuildSample(typeof(Subject)); Assert.That(notNull, Is.InstanceOf <Subject>()); }
public void BuildSample_Collections_AsInDecoration() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.Array, Is.EqualTo(new[] { "a", "b", "c" })); Assert.That(built.List, Is.EqualTo(new[] { '1', '2', '3' })); }
public void BuildSample_Enums_AsInDecoration() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.Enum, Is.EqualTo(DayOfWeek.Friday)); Assert.That(built.DateTimeOffset, Is.EqualTo(new DateTimeOffset(2018, 04, 06, 21, 42, 00, TimeSpan.Zero))); }
public void BuildSample_Dates_AsInDecoration() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.DateTime, Is.EqualTo(new DateTime(2018, 04, 06, 21, 39, 00, DateTimeKind.Utc))); Assert.That(built.DateTimeOffset, Is.EqualTo(new DateTimeOffset(2018, 04, 06, 21, 42, 00, TimeSpan.Zero))); }
public void BuildSample_UndecoratedProperties_AutofixtureRamdom() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.NotDecoratedScalar, Is.InstanceOf <string>().And.Not.Null); Assert.That(built.NotDecoratedObject, Is.InstanceOf <Exception>().And.Not.Null); }
public void AddPostProcessing__adds_post_processing() { var postProcessMock = new Mock<IPostProcessing>(); var postProcessObj = postProcessMock.Object; var fac = new SampleFactory(); fac.AddPostProcessing(postProcessObj); fac.PostProcessingFilters.Should().Contain(postProcessObj); }
public void BuildSample_ProxyType_DifferentInstanceBuilt() { var subject = new SampleFactory(); var built = subject.BuildSample(typeof(Proxy)); Assert.That(built, Is.Not.InstanceOf <Proxy>() .And.InstanceOf <Subject[]>()); }
public void BuildSample_Nullables_AsInDecoration() { var subject = new SampleFactory(); var built = (Subject)subject.BuildSample(typeof(Subject)); Assert.That(built.NullNullable, Is.Null); Assert.That(built.NotNullNullable, Is.EqualTo(8)); }
public void When_I_create_an_address_Then_it_should_return_a_valid_response_sync() { _profile = _service.Create(_profile); var address = SampleFactory.CreateSampleAddress(_profile); var response = _service.Create(address); Assert.That(response.Status(), Is.EqualTo("ACTIVE")); }
public void When_I_create_a_card_Then_it_should_return_a_valid_response_sync() { _profile = _service.Create(_profile); var card = SampleFactory.CreateSampleCard(_profile); var response = _service.Create(card); Assert.That(response.Status(), Is.EqualTo("ACTIVE")); }
public async Task When_I_verify_a_card_payment_Then_it_should_return_a_valid_response_async() { var service = SampleFactory.CreateSampleCardPaymentService(); var ver = SampleFactory.CreateSampleVerification(); var response = await service.VerifyAsync(ver); Assert.That(response.Status(), Is.EqualTo("COMPLETED")); }
public void Init() { _achDirectDebitService = SampleFactory.CreateSampleAchDirectDebitService(); _achPurchase = SampleFactory.CreateSampleAchPurchase(); _eftDirectDebitService = SampleFactory.CreateSampleEftDirectDebitService(); _eftPurchase = SampleFactory.CreateSampleEftPurchase(); _standaloneCredit = SampleFactory.CreateSampleEftStandaloneCredits(); }
public void Create__result_contains_samples() { var dive = new Dive(1, 400, 400, "image"); var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 5), new Pixel(5, 1) }).ToList(); var fac = new SampleFactory(); var processedDive = fac.Create(pixel, dive); processedDive.Samples.Count.Should().Be(pixel.Count); }
public ContentController() { var validatorFactory = new ValidatorFactory(); var timeMachine = new TimeMachine(); var logger = LogManager.GetLogger("Apinterest"); var sampleFactory = new SampleFactory(validatorFactory, timeMachine, logger); _routeExplorerService = new RouteExplorerService(GlobalConfiguration.Configuration.Services.GetApiExplorer(), sampleFactory); _resourceLookup = new ResourceLookup(Assembly.GetExecutingAssembly()); }
public void Setup() { MockValidatorFactory = new Mock<IValidatorFactory>(); MockValidatorFactory .Setup(f => f.GetValidator(It.IsAny<Type>(), It.IsAny<string>())) .Returns((Type type, string path) => new Validator { Path = path }); MockTimeMachine = new Mock<ITimeMachine>(); MockTimeMachine.Setup(t => t.DateTime).Returns(new DateTime(1983, 6, 13)); MockTimeMachine.Setup(t => t.Time).Returns(new TimeSpan(23, 58, 0)); Log = new Mock<ILog>(); SampleFactory = new SampleFactory(MockValidatorFactory.Object, MockTimeMachine.Object, Log.Object); }
public void Create__runs_mulitple_post_processing() { var dive = new Dive(1, 400, 400, "image"); var pixel = (new[] { new Pixel(0, 0), new SkipPixel(1, 2), new SkipPixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList(); var postProcess1 = new Mock<IPostProcessing>(); var postProcess2 = new Mock<IPostProcessing>(); var fac = new SampleFactory(); fac.AddPostProcessing(postProcess1.Object); fac.AddPostProcessing(postProcess2.Object); var processedDive = fac.Create(pixel, dive); postProcess1.Verify(pp => pp.Process(processedDive), Times.Once()); postProcess2.Verify(pp => pp.Process(processedDive), Times.Once()); }
public void Create__calculate_average_for_skip_pixels() { throw new NotImplementedException("implement"); var dive = new Dive(1, 400, 400, "image"); var pixel = (new[] { new Pixel(0, 0), new SkipPixel(1, 2), new SkipPixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList(); var fac = new SampleFactory(); var processedDive = fac.Create(pixel, dive); processedDive.Samples.Should().HaveCount(3); processedDive.Samples[0].Depth.Should().Be(0); processedDive.Samples[0].SecondsSinceStart.Should().Be(0); processedDive.Samples[1].Depth.Should().Be(400); processedDive.Samples[1].SecondsSinceStart.Should().Be(300); processedDive.Samples[2].Depth.Should().Be(0); processedDive.Samples[2].SecondsSinceStart.Should().Be(400); }
public void GetDepthResolution__uses_origin_and_returns_correct_value() { var pixel = (new[] { new Pixel(51, 71), new Pixel(52, 73), new Pixel(53, 75), new Pixel(54, 80), new Pixel(55, 71), new Pixel(56, 71), new Pixel(57, 71), new Pixel(58, 71) }).ToList(); var dive = new Dive(2, 30, 2, "image"); var fac = new SampleFactory(); var ret1 = fac.GetDepthResolution(pixel, dive); ret1.Should().Be(3); }
public void GetDepthResolution__wont_fail_on_null_or_empty() { var dive = new Dive(1, 1, 2, "image"); var fac = new SampleFactory(); var ret1 = fac.GetDepthResolution(null, null); var ret2 = fac.GetDepthResolution(new List<Pixel> { }, null); ret1.Should().Be(-1); ret2.Should().Be(-1); }
public void GetTimeResolution__gets_resolution_round_up() { var dive = new Dive(1, 1, 68, "image"); var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 5), new Pixel(5, 3), new Pixel(6, 1) }).ToList(); var fac = new SampleFactory(); var resoluion = fac.GetTimeResolution(pixel, dive); resoluion.Should().Be(14); }
public void GetTimeResolution__removes_the_last_pixels_from_list() { var dive = new Dive(1, 1, 2, "image"); var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 1), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList(); var fac = new SampleFactory(); fac.GetTimeResolution(pixel, dive); pixel.Count().Should().Be(4); }
public void RemoveLastPlainFromPixelList__removes_the_last_pixels_from_list() { var dive = new Dive(1, 1, 2, "image"); var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 3), new Pixel(3, 5), new Pixel(4, 1), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList(); var fac = new SampleFactory(); fac.RemoveLastPlainFromPixelList(pixel); pixel.Count().Should().Be(4); pixel[0].X.Should().Be(1); pixel[1].X.Should().Be(2); pixel[2].X.Should().Be(3); pixel[3].X.Should().Be(4); }
public void Create__using_first_pixel_as_origin_and_returns_samples_having_correct_values() { var dive = new Dive(1, 400, 400, "image"); var pixel = (new[] { new Pixel(70, 50), new Pixel(71, 52), new Pixel(72, 54), new Pixel(73, 54), new Pixel(74, 50) }).ToList(); var fac = new SampleFactory(); var processedDive = fac.Create(pixel, dive); processedDive.Samples[0].Depth.Should().Be(0); processedDive.Samples[0].SecondsSinceStart.Should().Be(0); processedDive.Samples[1].Depth.Should().Be(200); processedDive.Samples[1].SecondsSinceStart.Should().Be(100); processedDive.Samples[2].Depth.Should().Be(400); processedDive.Samples[2].SecondsSinceStart.Should().Be(200); processedDive.Samples[3].Depth.Should().Be(400); processedDive.Samples[3].SecondsSinceStart.Should().Be(300); processedDive.Samples[4].Depth.Should().Be(0); processedDive.Samples[4].SecondsSinceStart.Should().Be(400); }
public void GetDepthResolution__returns_correct_value_with_rounding_up() { var pixel = (new[] { new Pixel(1, 1), new Pixel(2, 16), new Pixel(3, 15), new Pixel(4, 10), new Pixel(5, 1), new Pixel(6, 1), new Pixel(7, 1), new Pixel(8, 1) }).ToList(); var dive = new Dive(2, 30, 2, "image"); var fac = new SampleFactory(); var ret1 = fac.GetDepthResolution(pixel, dive); ret1.Should().Be(2); }
public void Create__samples_have_correct_values() { var dive = new Dive(1, 400, 400, "image"); var pixel = (new[] { new Pixel(0, 0), new Pixel(1, 2), new Pixel(2, 4), new Pixel(3, 4), new Pixel(4, 0) }).ToList(); var fac = new SampleFactory(); var processedDive = fac.Create(pixel, dive); processedDive.Samples[0].Depth.Should().Be(0); processedDive.Samples[0].SecondsSinceStart.Should().Be(0); processedDive.Samples[1].Depth.Should().Be(200); processedDive.Samples[1].SecondsSinceStart.Should().Be(100); processedDive.Samples[2].Depth.Should().Be(400); processedDive.Samples[2].SecondsSinceStart.Should().Be(200); processedDive.Samples[3].Depth.Should().Be(400); processedDive.Samples[3].SecondsSinceStart.Should().Be(300); processedDive.Samples[4].Depth.Should().Be(0); processedDive.Samples[4].SecondsSinceStart.Should().Be(400); }
public void RemoveLastPlainFromPixelList__wont_fail_on_null_or_empty() { var dive = new Dive(1, 1, 2, "image"); var fac = new SampleFactory(); fac.RemoveLastPlainFromPixelList(null); fac.RemoveLastPlainFromPixelList(new List<Pixel> { }); true.Should().BeTrue(); }