Esempio n. 1
0
        public void Validate_GetEvens_UsingCollectionAssert()
        {
            var sample = new SampleComponent();
            var evens  = sample.GetEvens(12, 4);

            CollectionAssert.AreEqual(new[] { 12, 14, 16, 18 }, evens);
        }
        public void Capitalize_Throws_Exception_When_Argument_Is_Null_Fluent_Assertion()
        {
            var component = new SampleComponent();

            //component.CapitalizeThis(null);
            FluentActions.Invoking(() => component.CapitalizeThis(null)).Should().Throw <ArgumentNullException>();
        }
        public override RenderFragment GetRenderFragment(SampleComponent selectedSampleComponent)
        {
            return(new RenderFragment(builder =>
            {
                int x = 0;
                builder.OpenElement(++x, "div");
                builder.AddAttribute(++x, "class", "ui row padding buttons");
                foreach (var item in Actions)
                {
                    builder.OpenElement(++x, "button");
                    builder.AddAttribute(++x, "class", "ui small button");
                    builder.AddAttribute <MouseEventArgs>(++x, "onclick",
                                                          EventCallback.Factory.Create <MouseEventArgs>(this, d => item.OnExecute(this.Component))
                                                          );
                    builder.AddContent(++x, item.Name);
                    builder.CloseElement();
                }
                builder.CloseElement();
                builder.OpenComponent <T>(++x);

                builder.AddAttribute(++x, "class", selectedSampleComponent == this ? "editable selected" : "");

                if (GetInternalComponents(selectedSampleComponent) != null)
                {
                    builder.AddAttribute(++x, "ChildContent", GetInternalComponents(selectedSampleComponent));
                }
                builder.AddComponentReferenceCapture(++x, d => Component = (T)d);
                builder.CloseComponent();
            }));
        }
            private bool IsValid(SampleComponent candidate, int2 gridSize, NativeList <SampleComponent> samples, NativeArray <PoissonCellComponent> cells, int maxRadius)
            {
                var candidatePosition  = candidate.Position;
                var candidateCellIndex = candidatePosition.y * gridSize.x + candidatePosition.x;

                if (candidatePosition.x >= 0 && candidatePosition.x < gridSize.x &&
                    candidatePosition.y >= 0 && candidatePosition.y < gridSize.y &&
                    cells[candidateCellIndex].SampleIndex == -1)
                {
                    var startX = math.max(0, candidatePosition.x - 2 * maxRadius);
                    var endX   = math.min(candidatePosition.x + 2 * maxRadius, gridSize.x);
                    var startY = math.max(0, candidatePosition.y - 2 * maxRadius);
                    var endY   = math.min(candidatePosition.y + 2 * maxRadius, gridSize.y);

                    for (var y = startY; y < endY; y++)
                    {
                        for (var x = startX; x < endX; x++)
                        {
                            var sampleIndex = cells[y * gridSize.x + x].SampleIndex - 1;
                            if (sampleIndex > -1)
                            {
                                var distance = math.distance(candidatePosition, samples[sampleIndex].Position);
                                if (distance < samples[sampleIndex].Radius + candidate.Radius)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                }
                return(false);
            }
Esempio n. 5
0
    public SampleComponent CreateComponent()
    {
        SampleComponent newComponent = new SampleComponent();

        newComponent.Initialize();
        components.Add(newComponent);
        return(newComponent);
    }
Esempio n. 6
0
 public override void Initialize()
 {
     Context.RemoveAllComponents();
     actor = new SampleComponent(0, 0, Context)
     {
         Filled = true
     };
 }
Esempio n. 7
0
        public void Validate_GetEvens()
        {
            var sample = new SampleComponent();
            var evens  = sample.GetEvens(12, 4);

            Assert.AreEqual(12, evens[0]);
            Assert.AreEqual(14, evens[1]);
            Assert.AreEqual(16, evens[2]);
            Assert.AreEqual(18, evens[3]);
        }
 public override RenderFragment GetInternalComponents(SampleComponent selectedSampleComponent)
 {
     return(new RenderFragment(builder =>
     {
         int i = 0;
         foreach (var item in InternalComponents)
         {
             builder.AddContent(i++, item.GetRenderFragment(selectedSampleComponent));
         }
     }));
 }
Esempio n. 9
0
        public void Find_Five_Temps_Over_100()
        {
            var sample = new SampleComponent();

            var results = sample.ComputeSamples();
            var query   = from s in results
                          where s.Temperature > 100.0
                          select s;

            Assert.AreEqual(5, query.Count());
        }
Esempio n. 10
0
        public void Find_Four_Highest_Temps()
        {
            var sample = new SampleComponent();

            var results = sample.ComputeSamples();
            var query   = (from s in results
                           orderby s.Temperature descending
                           select s.Temperature).Take(4);

            CollectionAssert.AreEqual(
                new [] { 106.7, 106.2, 105.2, 103.9 }, query.ToArray());
        }
Esempio n. 11
0
    // PUBLIC

    // PUBLIC STATIC

    // PRIVATE


    //******************************************************
    //******************************************************
    //**	GENERICS
    //******************************************************
    //******************************************************

    // PRIVATE

    ///	DEMO
    //
    //	NOTE: This is Unity-specific
    //
    //  NOTE:   There are MANY generics methods used in Unity API.
    //			All (I think) have non-generic alternatives (one is shown below)
    //
    ///</summary>
    private void _doDemoOfNativeGenerics()
    {
        //	GETTING A COMPONENT REFERENCE (WITHOUT USING GENERICS)
        SampleComponent sampleComponent1 = GetComponent(typeof(SampleComponent)) as SampleComponent;

        //	GETTING A COMPONENT REFERENCE (WITH GENERICS)
        //		NOTE: No need to cast (via 'as') here so syntax is more brief
        SampleComponent sampleComponent2 = GetComponent <SampleComponent>();

        //	DEBUG
        Debug.Log("	sampleComponent1: " + sampleComponent1);
        Debug.Log("	sampleComponent2: " + sampleComponent2);
    }
        public async void Select(SampleComponent x)
        {
            try
            {
                currentComponent = x;
                if (currentComponent != null)
                {
                    var t = currentComponent.ThisComponent.GetType();


                    Prop = t.GetProperties().Where(
                        prop => Attribute.IsDefined(prop, typeof(ParameterAttribute)))
                           .Select(d => new Tuple <string, object, PropertyInfo>("", this.currentComponent.ThisComponent, d)).ToList();



                    Methods = t.GetMethods().Where(
                        prop => Attribute.IsDefined(prop, typeof(ComponentActionAttribute)))
                              .Select(d => new Tuple <string, object, MethodInfo>("", this.currentComponent.ThisComponent, d)).ToList();


                    var NestedClasses = t.GetProperties().Where(
                        prop => Attribute.IsDefined(prop, typeof(NestedParamterAttribute))).ToList();

                    foreach (var item in NestedClasses)
                    {
                        var nt = item.PropertyType;


                        Prop.AddRange(nt.GetProperties().Where(
                                          prop => Attribute.IsDefined(prop, typeof(ParameterAttribute)))
                                      .Select(d => new Tuple <string, object, PropertyInfo>(item.Name, item.GetValue(this.currentComponent.ThisComponent), d)).ToList());

                        var nestedMethods = nt.GetMethods()
                                            .Where(prop => Attribute.IsDefined(prop, typeof(ComponentActionAttribute)))
                                            .Select(d => new Tuple <string, object, MethodInfo>(item.Name, item.GetValue(this.currentComponent.ThisComponent), d)).ToList();


                        Methods.AddRange(nestedMethods);
                    }

                    this.StateHasChanged();
                    await JsRuntime.InvokeVoidAsync("window.demo.initPropSheetElements");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void Find_Four_Highest_Temps_FluentAssertion()
        {
            var sample = new SampleComponent();

            var results = sample.ComputeSamples();
            var query   = (from s in results
                           orderby s.Temperature descending
                           select s.Temperature).Take(4);

            //CollectionAssert.AreEqual(
            //    new[] { 106.7, 106.2, 105.2, 103.9 }, query.ToArray());
            //IEnumerable expectedCollection = new[] { 106.7, 106.2, 105.2, 103.9 };
            query.ToArray().Should().IntersectWith(new[] { 106.7, 106.2, 105.2, 103.9 });
        }
Esempio n. 14
0
        public static async Task TestSetup(TestContext context)
        {
            Console.WriteLine("ABout to start the initalizer");
            FyipeTransport fyipeTransport = new FyipeTransport(apiUrl);
            Random         random         = new Random();
            int            num            = random.Next(78965);

            string     email      = "username" + num.ToString() + "@business.com";
            SampleUser sampleUser = new SampleUser(
                "Travis Jones",
                email, "12345678",
                "12345678",
                "HackerBay",
                "Analyst",
                10,
                "Mastercard",
                "5555555555554444",
                "123",
                "04/2025",
                "Atlanta",
                "Atlanta",
                "1009087",
                "USA",
                "plan_GoWIYiX2L8hwzx",
                "Analyst",
                "90004322356",
                "Github");
            ApiTestResponse response = await fyipeTransport.MakeApiRequestForTest("/user/signup", sampleUser);

            string token     = response.tokens.jwtAccessToken;
            string projectId = response.project._id;

            SampleComponent component = new SampleComponent("Component For Dotnet Testing");

            response = await fyipeTransport.MakeApiRequestForTest($"/component/{projectId}", component, token);

            string componentId = response._id;

            SampleComponent applog = new SampleComponent("Application Log for Dotnet Testing");

            response = await fyipeTransport.MakeApiRequestForTest($"/application-log/{projectId}/{componentId}/create", applog, token);

            applicationLogId  = response._id;
            applicationLogKey = response.key;

            Console.WriteLine($"Applog ID: {applicationLogId} key: {applicationLogKey}");
        }
Esempio n. 15
0
        public override void Initialize()
        {
            Context.RemoveAllComponents();
            ball = new SampleComponent(0, 0, Context)
            {
                Filled = false
            };

            var b = Context.Bounds;

            bounds = new Rectangle(b.Left + 10, b.Top + 10, b.Width - 10, b.Height - 15);
            bar    = new SampleComponent[(int)bounds.Width];

            for (int i = 0; i < bar.Length; i++)
            {
                bar[i]       = new SampleComponent(0, 0, Context);
                bar[i].Pixel = '.'.White();
            }

            StartAnimation();
        }
        public override RenderFragment GetRenderFragment(SampleComponent selectedSampleComponent)
        {
            return(new RenderFragment(builder =>
            {
                int x = 0;

                builder.OpenComponent <T>(++x);
                foreach (var item in Events)
                {
                    item.AddEventSub(++x, builder);
                    //  builder.AddAttribute(++x, item.Name, (EventCallback<>)item.Callback);
                }
                builder.AddAttribute(++x, "class", selectedSampleComponent == this ? "editable selected" : "");

                if (GetInternalComponents(selectedSampleComponent) != null)
                {
                    builder.AddAttribute(++x, "ChildContent", GetInternalComponents(selectedSampleComponent));
                }
                builder.AddComponentReferenceCapture(++x, d => Component = (T)d);
                builder.CloseComponent();
            }));
        }
            private void AddToFinal(int2 gridSize, ref NativeArray <PoissonCellComponent> requestCells, NativeList <PoissonCellComponent> validCellList, ref NativeList <SampleComponent> finalSamplesList, SampleComponent candidate)
            {
                var candidatePosition = candidate.Position;

                finalSamplesList.Add(candidate);
                this.RemoveFromValid(candidate.Position, validCellList);
                var cell = requestCells[candidatePosition.y * gridSize.x + candidatePosition.x];

                cell.SampleIndex = finalSamplesList.Length;
                requestCells[candidatePosition.y * gridSize.x + candidatePosition.x] = cell;

                var startX = math.max(0, candidatePosition.x - 2 * candidate.Radius);
                var endX   = math.min(candidatePosition.x + 2 * candidate.Radius, gridSize.x);
                var startY = math.max(0, candidatePosition.y - 2 * candidate.Radius);
                var endY   = math.min(candidatePosition.y + 2 * candidate.Radius, gridSize.y);

                for (var y = startY; y < endY; y++)
                {
                    for (var x = startX; x < endX; x++)
                    {
                        this.RemoveFromValid(new int2(x, y), validCellList);
                    }
                }
            }
            public void Execute([ReadOnly] ref PoissonDiscSamplingComponent poissonDiscSamplingComponent)
            {
                var gridSize      = poissonDiscSamplingComponent.GridSize;
                var requestCells  = this.GetCellsByRequestID(poissonDiscSamplingComponent.RequestID, gridSize);
                var validCellList = this.GetValidCells(requestCells);

                if (validCellList.Length == 0)
                {
                    return;
                }

                var finalSamplesList   = new NativeList <SampleComponent>(Allocator.Temp);
                var currentSamplesList = new NativeList <SampleComponent>(Allocator.Temp);
                var random             = new Random((uint)this.RandomSeed + 1);
                var maxRadius          = poissonDiscSamplingComponent.Radius;
                var requestRadiuses    = new NativeList <int>(Allocator.Temp);

                if (poissonDiscSamplingComponent.RadiusFromArray == 1)
                {
                    for (var i = 0; i < this.Radiuses.Length; i++)
                    {
                        if (this.Radiuses[i].RequestID == poissonDiscSamplingComponent.RequestID)
                        {
                            requestRadiuses.Add(this.Radiuses[i].Radius);
                            if (maxRadius < this.Radiuses[i].Radius)
                            {
                                maxRadius = this.Radiuses[i].Radius;
                            }
                        }
                    }
                }

                var randomIndex  = random.NextInt(0, validCellList.Length);
                var randomCell   = validCellList[randomIndex];
                var randomSample = new SampleComponent
                {
                    Radius    = maxRadius,
                    RequestID = poissonDiscSamplingComponent.RequestID,
                    Position  = randomCell.Position
                };

                currentSamplesList.Add(randomSample);
                finalSamplesList.Add(randomSample);
                this.RemoveFromValid(randomSample.Position, validCellList);
                var cell = requestCells[randomSample.Position.y * gridSize.x + randomSample.Position.x];

                cell.SampleIndex = finalSamplesList.Length;
                requestCells[randomSample.Position.y * gridSize.x + randomSample.Position.x] = cell;

                while (validCellList.Length > 0)
                {
                    if (currentSamplesList.Length == 0)
                    {
                        randomIndex = random.NextInt(0, validCellList.Length);
                        randomCell  = validCellList[randomIndex];
                        var candidate = new SampleComponent
                        {
                            Radius    = maxRadius,
                            RequestID = poissonDiscSamplingComponent.RequestID,
                            Position  = randomCell.Position
                        };

                        currentSamplesList.Add(candidate);
                        if (this.IsValid(candidate, gridSize, finalSamplesList, requestCells, maxRadius))
                        {
                            this.AddToFinal(gridSize, ref requestCells, validCellList, ref finalSamplesList, candidate);
                        }
                        else
                        {
                            this.RemoveFromValid(candidate.Position, validCellList);
                        }
                    }
                    else
                    {
                        var candidateFound = false;

                        randomIndex  = random.NextInt(0, currentSamplesList.Length);
                        randomSample = currentSamplesList[randomIndex];

                        for (var i = 0; i < poissonDiscSamplingComponent.SamplesLimit; i++)
                        {
                            var randomAngle     = random.NextInt() * math.PI * 2;
                            var randomDirection = new float2(math.sin(randomAngle), math.cos(randomAngle));
                            var radius          = maxRadius;
                            var stepRadius      = radius;
                            if (poissonDiscSamplingComponent.RadiusFromArray == 1)
                            {
                                radius     = requestRadiuses[random.NextInt(0, requestRadiuses.Length)];
                                stepRadius = math.max(radius, maxRadius);
                            }

                            var candidate = new SampleComponent
                            {
                                Radius    = radius,
                                RequestID = poissonDiscSamplingComponent.RequestID,
                                Position  =
                                    (int2)(randomSample.Position + randomDirection *
                                           random.NextInt(stepRadius, 2 * stepRadius))
                            };

                            if (this.IsValid(candidate, gridSize, finalSamplesList, requestCells, maxRadius))
                            {
                                this.AddToFinal(gridSize, ref requestCells, validCellList, ref finalSamplesList, candidate);
                                candidateFound = true;
                                break;
                            }
                        }
                        if (!candidateFound)
                        {
                            currentSamplesList.RemoveAtSwapBack(randomIndex);
                            this.RemoveFromValid(randomSample.Position, validCellList);
                        }
                    }
                }

                for (var i = 0; i < finalSamplesList.Length; i++)
                {
                    this.ResultQueue.Enqueue(finalSamplesList[i]);
                }
            }
Esempio n. 19
0
        public void Capitalize_Throws_Exception_When_Argument_Is_Null()
        {
            var component = new SampleComponent();

            component.CapitalizeThis(null);
        }
 public SampleComponentEventWithChildren(string variableName, SampleComponent parentComponent, Action <T> onComponentCreate = null) : base(parentComponent, onComponentCreate)
 {
     VariableName = variableName;
 }
 public void Close()
 {
     currentComponent = null;
     isEditing        = false;
     this.StateHasChanged();
 }
        public async void Open()
        {
            currentComponent = null;

            await JsRuntime.InvokeVoidAsync("window.demo.togglePropSheet", sideMenu1, sideMenu2, DotNetObjectReference.Create(this));
        }