Fail() static public method

Throws an AssertionException. This is used by the other Assert functions.
static public Fail ( ) : void
return void
コード例 #1
0
        public void Buffer()
        {
            Coordinate[] c   = new Coordinate[36];
            Random       rnd = new Random();

            for (int i = 0; i < 36; i++)
            {
                c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90);
            }
            MultiPoint mps = new MultiPoint(c);

            byte[]     vals     = mps.ToBinary();
            WkbReader  wkb      = new WkbReader();
            IGeometry  g        = wkb.Read(vals);
            MultiPoint mpsCheck = g as MultiPoint;

            if (mpsCheck != null)
            {
                Assert.AreEqual(mps.Buffer(200).Area, mpsCheck.Buffer(200).Area);
            }
            else
            {
                Assert.Fail("The test failed because the MpsCheck  was null.");
            }
        }
コード例 #2
0
 [Test] //produto inexistente
 public void BuscarProdutoTest_ProdInexistente()
 {
     if (_produtoRepository.BuscarProduto(_produtoTeste.User) != null)
     {
         Assert.Fail();
     }
 }
コード例 #3
0
        public void GetHtmlAsyncPromises()
        {
            bool p1resolved = false;
            bool p2resolved = false;

            var promise1 = CQ.CreateFromUrlAsync(urls[0].Key)
                           .Then(new Action <ICsqWebResponse>((resp) => {
                Assert.IsTrue(resp.Dom.Find(urls[0].Value).Length > 0, "I found an expected content container - if MS changed their web site this could fail.");
                p1resolved = true;
            }));

            var promise2 = CQ.CreateFromUrlAsync(urls[1].Key).Then(new Action <ICsqWebResponse>((resp) =>
            {
                Assert.IsTrue(resp.Dom.Find(urls[1].Value).Length > 0, "I found an expected content container - if CNN changed their web site this could fail.");
                p2resolved = true;
            }));

            bool complete = false;

            CQ.WhenAll(promise1, promise2).Then(new Action <ICsqWebResponse>((response) =>
            {
                Assert.IsTrue(p1resolved, "Promise 1 is resolved");
                Assert.IsTrue(p2resolved, "Promise 1 is resolved");
                complete = true;
            }), new Action(() =>
            {
                Assert.Fail("The web requests were rejected.");
            }));

            // if we don't do this the test will exit before finishing
            CQ.WaitForAsyncEvents(10000);

            Assert.IsTrue(complete);
        }
コード例 #4
0
        public void Projection_write_speed_without_unit_of_work()
        {
            var eventsRead = 0;

            var projector1 = Projector.Create <IEvent>(e =>
            {
                using (var db = ReadModelDbContext())
                {
                    db.Set <ProductInventory>().Add(new ProductInventory
                    {
                        ProductName      = Guid.NewGuid().ToString(),
                        QuantityInStock  = Any.Int(1, 5),
                        QuantityReserved = 0
                    });

                    db.SaveChanges();

                    eventsRead++;
                }
            }).Named(MethodBase.GetCurrentMethod().Name + ":projector1");

            using (var catchup = new ReadModelCatchup(
                       eventStoreDbContext: () => EventStoreDbContext(),
                       readModelDbContext: () => ReadModelDbContext(),
                       startAtEventId: startAtEventId, projectors: projector1))
            {
                catchup.Run();
            }

            Console.WriteLine(new { eventsRead });

            // TODO: (Write_speed_without_unit_of_work) write test
            Assert.Fail("Test not written yet.");
        }
コード例 #5
0
        [Test] //inativar produto de outro usuário
        public void InativaProdutoTest_Outro()
        {
            _produtoTeste.Ativo    = true;
            _produtoTeste.Quantity = 1;
            _produtoRepository.AtualizarProduto(_produtoTeste.User, _produtoTeste.Id, _produtoTeste);

            if (_produtoTeste.Ativo)
            {
                var teste = _produtoRepository.InativaProduto(_produtoTeste.Id, _produtoTeste.Id);
                if (teste != null)
                {
                    if (teste.Ativo != _produtoTeste.Ativo)
                    {
                        Assert.Fail();
                    }
                }
            }
            else
            {
                var teste = _produtoRepository.InativaProduto(_produtoTeste.Id, _produtoTeste.Id);
                if (teste != null)
                {
                    Assert.Fail();
                }
            }
        }
コード例 #6
0
        [Test] //alterar endereco cadastrado no usuário
        public void AtualizarEnderecoTest()
        {
            try
            {
                var alterar = _enderecoRepository.BuscarEndereco(_enderecoTeste.Id);
                alterar.Rua = "Nova Rua";
                var alterado = _enderecoRepository.AtualizarEndereco(_enderecoTeste.User, _enderecoTeste.Id, alterar);

                if (alterado == null)
                {
                    Assert.Fail();
                }
                else
                {
                    if (alterar.Rua != alterado.Rua)
                    {
                        Assert.Fail();
                    }
                }
            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
コード例 #7
0
        public void GenerateForMembers_compiles_expressions_that_are_not_MemberExpressions()
        {
            var node = new Node {
                Id = "1", Nodes = new[] { new Node {
                                              Id = "1.1"
                                          }, new Node {
                                              Id = "1.2"
                                          } }
            };

            Formatter <Node> .RegisterForAllMembers();

            Console.WriteLine(node.ToLogString());

            Formatter <Node> .GenerateForMembers(
                di => di.Id,
                di => di.Nodes.Select(n => n.Id).ToLogString());

            Assert.That(
                node.ToLogString(),
                Is.StringContaining("Nodes = {  }"));

            // TODO (GenerateForMembers_compiles_expressions_that_are_not_MemberExpressions) write test
            Assert.Fail("Test not written yet.");
        }
コード例 #8
0
        public virtual void TestGetProperty()
        {
            var culture = Thread.CurrentThread.CurrentCulture;

            try {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                var obj = NewTestObject <Object1>();

                obj.GetPropertyByName("Prop1");
                obj.GetPropertyByName("Bar");

                obj.GetPropertyById("Prop1");
                obj.GetPropertyById("Prop2");

                try {
                    obj.GetPropertyById("Bar");
                    Assert.Fail("Shouldn't get to here!");
                }
                catch (Exception e) {
                    Assert.AreEqual("Assert.Fail failed. No Property with Id 'Bar'", e.Message);
                }

                try {
                    obj.GetPropertyByName("Prop4");
                    Assert.Fail("Shouldn't get to here!");
                }
                catch (Exception e) {
                    Assert.AreEqual("Assert.Fail failed. No Property named 'Prop4'", e.Message);
                }
            }
            finally {
                Thread.CurrentThread.CurrentCulture = culture;
            }
        }
コード例 #9
0
        public void AddForm_Test()
        {
            try
            {
                List <QuestionDTO> q = new List <QuestionDTO>();
                List <AnswerDTO>   a = new List <AnswerDTO>();
                a.Add(new AnswerDTO {
                    Answer = "a", AnswerID = 20
                });

                q.Add(new QuestionDTO {
                    QuestionID = 1, Question = "why?", Answers = a
                });

                FormDetailDTO f = new FormDetailDTO()
                {
                    Id        = 4,
                    Username  = "******",
                    Deadline  = "3",
                    Category  = "category1",
                    Title     = "Title1",
                    State     = "open",
                    NrVotes   = 100,
                    Questions = q
                };

                _formLogic.AddForm(f);
            }
            catch (Exception)
            {
                Assert.Pass();
            }
            Assert.Fail();
        }
コード例 #10
0
ファイル: ActionEngine.cs プロジェクト: purna1221/Microsite
        public bool waitForVisibilityOfElementUntillTimeout(By lookupBy, double timeout)
        {
            bool          bln  = false;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));

            try
            {
                WebElement ele = wait.Until(ExpectedConditions.ElementIsVisible(lookupBy));//sunil
                bln = true;
            }
            catch (Exception ex)
            {
                try
                {
                    TakeScreenShot();
                    Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
                    throw new Exception(ex.Message);
                }
                catch (Exception ex1)
                {
                    Assert.Fail("Failed to take screenshot: " + ex1.ToString());
                }
            }

            return(bln);
        }
コード例 #11
0
        public void GetHtmlAsyncPromises()
        {
            bool p1resolved = false;
            bool p2resolved = false;

            var promise1 = CQ.CreateFromUrlAsync("http://www.microsoft.com/en/us/default.aspx?redir=true")
                           .Then(new Action <ICsqWebResponse>((resp) => {
                Assert.IsTrue(resp.Dom.Find(".hpMst_Stage").Length == 1, "I found an expected content container - if MS changed their web site this could fail.");
                p1resolved = true;
            }));

            var promise2 = CQ.CreateFromUrlAsync("http://www.cnn.com/").Then(new Action <ICsqWebResponse>((resp) =>
            {
                Assert.IsTrue(resp.Dom.Find("#cnn_hdr").Length == 1, "I found an expected content container - if CNN changed their web site this could fail.");
                p2resolved = true;
            }));

            bool complete = false;

            CQ.WhenAll(promise1, promise2).Then(new Action <ICsqWebResponse>((response) =>
            {
                Assert.IsTrue(p1resolved, "Promise 1 is resolved");
                Assert.IsTrue(p2resolved, "Promise 1 is resolved");
                complete = true;
            }), new Action(() =>
            {
                Assert.Fail("The web requests were rejected.");
            }));

            // if we don't do this the test will exit before finishing
            CQ.WaitForAsyncEvents(10000);

            Assert.IsTrue(complete);
        }
コード例 #12
0
        private static void GetTwoUsers(AccountUnitOfWork unit, [CallerMemberName] string caller = null)
        {
            var result = unit.RegisterUserAsync(new TelimenaUser(caller + "*****@*****.**", caller + "Jim Beam"), "P@ssword", TelimenaRoles.Developer).GetAwaiter()
                         .GetResult();

            if (!result.Item1.Succeeded)
            {
                var msg = result.Item1.Errors?.FirstOrDefault();
                if (msg != null && !msg.Contains("is already taken."))
                {
                    Assert.Fail($"Failed to register user. Error: {result.Item1.Errors?.FirstOrDefault()}");
                }
            }
            unit.Complete();

            result = unit.RegisterUserAsync(new TelimenaUser(caller + "*****@*****.**", caller + "Jack Daniels"), "P@ssword", TelimenaRoles.Developer).GetAwaiter()
                     .GetResult();
            if (!result.Item1.Succeeded)
            {
                var msg = result.Item1.Errors?.FirstOrDefault();
                if (msg != null && !msg.Contains("is already taken."))
                {
                    Assert.Fail($"Failed to register user. Error: {result.Item1.Errors?.FirstOrDefault()}");
                }
            }
            unit.Complete();
        }
コード例 #13
0
        public void TestGetCo2()
        {
            var url = "https://localhost:5001/measurements?deviceEUI=0004A30B00219CAC";

            try {
                var myRequest = (HttpWebRequest)WebRequest.Create(url);
                var response  = (HttpWebResponse)myRequest.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    if (response.)
                    {
                        Console.Write(string.Format("{0} Available", url));
                    }
                }
                else
                {
                    Assert.Warn(string.Format("{0} Returned, but with status: {1}",
                                              url, response.StatusDescription));
                }
            }
            catch (Exception ex) {
                Console.Write(string.Format("{0} unavailable: {1}", url, ex.Message));
                Assert.Fail();
            }

            using (var client = new HttpClient()) {
                String URL      = "https://localhost:5001/CO2";
                var    response = client.GetStringAsync(URL);
                Assert.IsTrue(Int16.Parse(response.Result) < 5000 && Int16.Parse(response.Result) > 410);
            }
        }
コード例 #14
0
 public void MultiLine()
 {
     Formatter.TextFormatter = new MultiLineTextFormatter();
     WriteSomething();
     // TODO (SingleLineTextFormatter) write test
     Assert.Fail("Test not written yet.");
 }
コード例 #15
0
ファイル: AsyncTests.cs プロジェクト: tuga1975/Its.Validation
        public void Rules_within_a_ValidationPlan_can_use_APM_signatures_and_run_synchronously()
        {
            var hasAwesomeTag = Validate.Async <string>(
                setup: url =>
            {
                var request = new ApmOperation <string, string>(s =>
                                                                Task <string> .Factory.StartNew(() => "<div>" + s + "</div>"));
                var tcs = new TaskCompletionSource <string>();
                Task <string> .Factory
                .FromAsync(request.BeginInvoke,
                           request.EndInvoke,
                           url,
                           state: null)
                .ContinueWith(
                    t => tcs.Complete(t, () => t.Result));
                return(tcs.Task);
            },
                validate: html => html.As("page").Contains("<awesome>"))
                                .WithErrorMessage("{page} is missing the <awesome> tag!");

            var plan = new ValidationPlan <string>
            {
                isValidHttpUrl,
                hasAwesomeTag.When(isValidHttpUrl)
            };

            var result = plan.Execute("http://microsoft.com");

            Console.WriteLine(result);

            // TODO: (Rules_within_a_ValidationPlan_can_use_APM_signatures_and_run_synchronously)
            Assert.Fail("Test not written");
        }
コード例 #16
0
        internal void ValidateAddcertifications()
        {
            //Validate the certification is added sucessfully
            try
            {
                ExcelLibHelper.PopulateInCollection(ConstantHelpers.TestDataPath, "FieldValues");
                String expectedValue = ExcelLibHelper.ReadData(3, "Certificate");

                //Get the table list
                IList <IWebElement> Trows = driver.FindElements(By.XPath("//form/div[5]/div[1]/div[2]/div/table/tbody/tr"));

                //Get the row count in table
                var rows = Trows.Count;
                for (var i = 1; i <= rows; i++)
                {
                    ExtentionHelpers.TurnOnWait(driver);
                    string actualValue = driver.FindElement(By.XPath("//form/div[5]/div/div[2]/div/table/tbody[" + i + "]/tr/td[1]")).Text;

                    //Check if expected value is equal to actual value
                    if (expectedValue == actualValue)
                    {
                        SaveScreenShotClass save = new SaveScreenShotClass();
                        string img = save.SaveScreenshot(driver, "certification added");
                    }
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
            ExtentionHelpers.TurnOnWait(driver);
        }
コード例 #17
0
        public void CadastroEnderecoTest()
        {
            Endereco novo = new Endereco();

            novo.Bairro       = "Vila Paiva";
            novo.Cep          = "02075040";
            novo.Cidade       = "São Paulo";
            novo.Uf           = "SP";
            novo.User         = _enderecoTeste.User;
            novo.NomeEndereco = "Teste unitário";
            novo.Numero       = 396;
            novo.Rua          = "Manuel de Almeida";

            try
            {
                if (novo != null)
                {
                    _enderecoRepository.CadastroEndereco(novo);
                }
                var teste = _enderecoRepository.BuscarEnderecoPorNome(novo.NomeEndereco).FirstOrDefault();

                if (teste == null)
                {
                    Assert.Fail();
                }
                else
                {
                    _enderecoRepository.RemoverEndereco(teste.Id);
                }
            }
            catch (System.Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
コード例 #18
0
        //validate deletion
        internal void ValidateDeleteLanguage()
        {
            try
            {
                String expectedValue1 = ExcelLibHelper.ReadData(3, "Language");

                //get the table list
                IList <IWebElement> Tablerows = driver.FindElements(By.XPath("//form/div[2]/div/div[2]/div/table/tbody/tr"));

                for (int i = 1; i <= Tablerows.Count; i++)
                {
                    string actualvalue1 = driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td[1]")).Text;

                    //check if expected value is  not equal to actual value
                    if (expectedValue1 != actualvalue1)
                    {
                        SaveScreenShotClass save = new SaveScreenShotClass();
                        string img = save.SaveScreenshot(driver, "LanguageDeleted");

                        Console.WriteLine("deleted Successfully");
                    }
                }
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
コード例 #19
0
        public void Errors_during_catchup_result_in_retries()
        {
            var consequenter = Consequenter.Create <Order.CreditCardCharged>(e => { })
                               .UseServiceBusForDurability(new ServiceBusSettings
            {
                ConnectionString = "this will never work"
            });

            var errors      = new List <EventHandlingError>();
            var aggregateId = Any.Guid();

            Events.Write(1, i => new Order.CreditCardCharged
            {
                AggregateId = aggregateId
            });

            using (Domain.Configuration.Global.EventBus.Errors.Subscribe(errors.Add))
                using (var catchup = CreateReadModelCatchup <CommandSchedulerDbContext>(consequenter))
                {
                    catchup.Run();

                    errors.Should().Contain(e => e.AggregateId == aggregateId &&
                                            e.Exception.ToString().Contains("excelsior!"));
                }

            // TODO (Errors_during_catchup_result_in_retries) this would require a slightly different catchup mechanism or a way to retry events found in the EventHandlingErrors table
            Assert.Fail("Test not written yet.");
        }
コード例 #20
0
        public void MultipolygonToByteArray()
        {
            var rnd = new Random();
            var pg  = new Polygon[50];

            for (var i = 0; i < 50; i++)
            {
                var center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                var coord  = new Coordinate[36];
                for (var ii = 0; ii < 36; ii++)
                {
                    coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                }
                coord[35] = new Coordinate(coord[0].X, coord[0].Y);
                pg[i]     = new Polygon(coord);
            }
            var mpg      = new MultiPolygon(pg);
            var vals     = mpg.ToBinary();
            var wkr      = new WkbReader();
            var g        = wkr.Read(vals);
            var mpgcheck = g as MultiPolygon;

            if (mpgcheck != null)
            {
                for (var ii = 0; ii < mpg.Coordinates.Count; ii++)
                {
                    Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X);
                    Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y);
                }
            }
            else
            {
                Assert.Fail("The test failed bc the check mpgcheck was null.");
            }
        }
コード例 #21
0
ファイル: UpdateTests.cs プロジェクト: AmpScm/SharpSvn
        public void UpdateInUse()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk"), 1), dir);

            using (File.OpenRead(Path.Combine(dir, "index.html")))
                using (new Implementation.SvnFsOperationRetryOverride(0))
                {
                    SvnSystemException se = null;
                    try
                    {
                        Client.Update(Path.Combine(dir, "index.html"));
                        Assert.Fail("Should have failed");
                    }
                    catch (SvnWorkingCopyException e)
                    {
                        Assert.That(e.Message, Does.StartWith("Failed to run the WC DB"));
                        se = e.GetCause <SvnSystemException>();
                    }


                    Assert.That(se, Is.Not.Null, "Have system exception");
                    Assert.That(se.Message, Does.Contain("Can't move"));
                }
        }
コード例 #22
0
        public void MultiLsToByteArray()
        {
            var rnd = new Random();
            var ls  = new LineString[40];

            for (var ii = 0; ii < 40; ii++)
            {
                var coord = new Coordinate[36];
                for (var i = 0; i < 36; i++)
                {
                    coord[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                }
                ls[ii] = new LineString(coord);
            }
            var mls      = new MultiLineString(ls);
            var vals     = mls.ToBinary();
            var wkr      = new WkbReader();
            var g        = wkr.Read(vals);
            var mlscheck = g as MultiLineString;

            if (mlscheck != null)
            {
                for (var ii = 0; ii < mls.Coordinates.Count; ii++)
                {
                    Assert.AreEqual(mls.Coordinates[ii].X, mlscheck.Coordinates[ii].X);
                    Assert.AreEqual(mls.Coordinates[ii].Y, mlscheck.Coordinates[ii].Y);
                }
            }
            else
            {
                Assert.Fail("The test failed bc the check multilinestring was null.");
            }
        }
コード例 #23
0
        public void Init()
        {
            var console = new ConsoleControl();

            //typeof(MainWindow).GetProperty("Console")?.SetValue(null, console);

            App.Console = console;

            File.Create(Filename1).Close();

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                _filename2 = Filename2Win;
                break;

            case PlatformID.MacOSX:
            case PlatformID.Unix:
                _filename2 = Filename2Unix;
                break;

            default:
                Assert.Fail($"Why the f**k are you running this on {Enum.GetName(typeof(PlatformID), Environment.OSVersion.Platform)}?");
                break;
            }
        }
コード例 #24
0
        public void MultiPointToByteArray()
        {
            var c   = new Coordinate[36];
            var rnd = new Random();

            for (var i = 0; i < 36; i++)
            {
                c[i] = new Coordinate((rnd.NextDouble() + 360) - 180, (rnd.NextDouble() * 180) - 90);
            }
            var mps      = new MultiPoint(c);
            var vals     = mps.ToBinary();
            var wkb      = new WkbReader();
            var g        = wkb.Read(vals);
            var mpsCheck = g as MultiPoint;

            if (mpsCheck != null)
            {
                for (var ii = 0; ii < mps.Coordinates.Count; ii++)
                {
                    Assert.AreEqual(mps.Coordinates[ii].X, mpsCheck.Coordinates[ii].X);
                    Assert.AreEqual(mps.Coordinates[ii].Y, mpsCheck.Coordinates[ii].Y);
                }
            }
            else
            {
                Assert.Fail("The test failed because the MpsCheck  was null.");
            }
        }
コード例 #25
0
 [Test] //produto existente
 public void BuscarProdutoTest()
 {
     if (_produtoRepository.BuscarProduto(_produtoTeste.Id) == null)
     {
         Assert.Fail();
     }
 }
コード例 #26
0
        public void LsToByteArray()
        {
            var coords = new Coordinate[36];
            var rnd    = new Random();

            for (var i = 0; i < 36; i++)
            {
                coords[i] = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
            }
            var ls      = new LineString(coords);
            var vals    = ls.ToBinary();
            var wkr     = new WkbReader();
            var g       = wkr.Read(vals);
            var lscheck = g as LineString;

            if (lscheck != null)
            {
                for (var i = 0; i < ls.Count; i++)
                {
                    Assert.AreEqual(ls.Coordinates[i].X, lscheck.Coordinates[i].X);
                    Assert.AreEqual(ls.Coordinates[i].Y, lscheck.Coordinates[i].Y);
                }
                Assert.AreEqual(ls.Length, lscheck.Length);
                Assert.AreEqual(ls.Envelope.Height, lscheck.Envelope.Height);
                Assert.AreEqual(ls.Envelope.Width, lscheck.Envelope.Width);
            }
            else
            {
                Assert.Fail("The test failed bc the check lscheck was null.");
            }
        }
コード例 #27
0
 [Test] //buscar por usuário inexistente
 public void BuscarProdutosPorUsuarioTest_UserInexistente()
 {
     if (_produtoRepository.BuscarProdutosPorUsuario(_produtoTeste.Id) == null)
     {
         Assert.Fail();
     }
 }
コード例 #28
0
        public void TestGoogleDriveV3(string fileName)
        {
            Console.WriteLine("Some text here");
            // arrange

            //var test = new GoogleDriveApi();

            // act

            List <string> file = getFileNames();

            if (file.Count == 0)
            {
                Assert.Fail("Something wrong on google disk");
            }

            // assert

            bool equal = false;

            foreach (var f in file)
            {
                NUnit.Framework.TestContext.WriteLine(f);;
                if (f == fileName)
                {
                    equal = true;
                }
            }

            Assert.IsTrue(equal == true);
        }
コード例 #29
0
    public IEnumerator TestAssetReferenceTMethod()
    {
        yield return(ValidateTestDependency());

        PreInstall();

        Container.BindAsync <GameObject>()
        .FromAssetReferenceT(addressablePrefabReference)
        .AsCached();
        PostInstall();

        AddressableInject <GameObject> asyncPrefab = Container.Resolve <AddressableInject <GameObject> >();

        int frameCounter = 0;

        while (!asyncPrefab.HasResult && !asyncPrefab.IsFaulted)
        {
            frameCounter++;
            if (frameCounter > 10000)
            {
                Assert.Fail();
            }
            yield return(null);
        }

        Addressables.Release(asyncPrefab.AssetReferenceHandle);
        Assert.Pass();
    }
コード例 #30
0
ファイル: OrderServiceTests.cs プロジェクト: blfortier/TDD
        public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
        {
            var shoppingCart = new ShoppingCart();

            shoppingCart.Items.Add(new ShoppingCartItem {
                ItemId = Guid.NewGuid(), Quantity = 0
            });
            var customerId      = Guid.NewGuid();
            var expectedOrderId = Guid.NewGuid();

            Mock.Arrange(() => _orderDataService.Save(Arg.IsAny <Order>()))
            .Returns(expectedOrderId)
            .OccursNever();
            // Act
            try
            {
                _orderService.PlaceOrder(customerId, shoppingCart);
            }
            catch
            {
                // Assert
                Mock.Assert(_orderDataService);
                Assert.Pass();
            }

            Assert.Fail();
        }