Example #1
0
        public void GetAllStock_ShouldReturnCorrectStock()
        {
            // Arrange
            var arrangements = new Arrangements();

            var catalogStock = new List <CatalogModel>();

            catalogStock.Add(
                new CatalogModel
            {
                Description = "Macbook",
                Price       = 200,
                Qauntity    = 10
            });

            catalogStock.Add(
                new CatalogModel
            {
                Description = "iPad",
                Price       = 100,
                Qauntity    = 5
            });


            // Act
            var result = arrangements.SUT.GetAllStock();

            // Assert
            result.Should().BeEquivalentTo(catalogStock);
        }
        public void UpconvertGivenUpconverterAToBAndCAndUpconvertCToD_WithEventA_ShouldReturnEventBAndEventD()
        {
            // Arrange
            var sut = new Arrangements()
                      .AddUpconverter <EventA>(UpconvertMethod)
                      .AddUpconverter <EventC, EventD>(x => new EventD(x.Count))
                      .BuildAndGetSUT();
            var source    = new EventA("Mr. Silly Name", 4);
            var expectedB = new EventB(source.Name, source.Count);
            var expectedD = new EventD(source.Count);

            // Act
            var upconverted = sut.Upconvert(new [] { new ItemWithType(source) });

            // Assert
            upconverted.Should().NotBeNullOrEmpty();
            upconverted.Count().Should().Be(2);
            upconverted.ToArray()[0].type.Should().Be <EventB>();
            upconverted.ToArray()[0].instance.As <EventB>().MyName.Should().Be(expectedB.MyName);
            upconverted.ToArray()[0].instance.As <EventB>().Count.Should().Be(expectedB.Count);
            upconverted.ToArray()[1].type.Should().Be <EventD>();
            upconverted.ToArray()[1].instance.As <EventD>().MyCount.Should().Be(expectedD.MyCount);

            IEnumerable <object> UpconvertMethod(EventA a)
            {
                yield return(new EventB(a.Name, a.Count));

                yield return(new EventC(a.Count));
            }
        }
Example #3
0
        public void Write(BinaryWriter w)
        {
            BPMs.Write(w);
            Phrases.Write(w);
            Chords.Write(w);
            ChordNotes.Write(w);
            Vocals.Write(w);

            if (Vocals.Count > 0)
            {
                SymbolsHeader.Write(w);
                SymbolsTexture.Write(w);
                SymbolsDefinition.Write(w);
            }

            PhraseIterations.Write(w);
            PhraseExtraInfo.Write(w);
            NLD.Write(w);
            Actions.Write(w);
            Events.Write(w);
            Tones.Write(w);
            DNAs.Write(w);
            Sections.Write(w);
            Arrangements.Write(w);
            Meta.Write(w);
        }
 /// <summary>
 /// Creates a new instance of the <see cref="ArrangementCollection"/> type.
 /// </summary>
 /// <param name="arrangements">
 /// An array of initial <see cref="IArrangement"/>s that should be stored within the collection.
 /// </param>
 public ArrangementCollection(params IArrangement[] arrangements)
 {
     if (arrangements != null)
     {
         Arrangements.AddRange(arrangements);
     }
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ArrangementCollection"/> type.
 /// </summary>
 /// <param name="arrangements">
 /// An array of initial <see cref="IArrangement"/>s that should be stored within the collection.
 /// </param>
 public ArrangementCollection(IEnumerable <IArrangement>?arrangements)
 {
     if (arrangements != null)
     {
         Arrangements.AddRange(arrangements);
     }
 }
Example #6
0
 public ActionResult CreateArrangement(Arrangements CreatedArrangement)
 {
     CreatedArrangement.Id      = Guid.NewGuid();
     CreatedArrangement.Created = DateTime.Now;
     DB.Arrangements.Add(CreatedArrangement);
     DB.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public void CheckIfUpconvertersExistOrThrow_WithThreEventsAndAllUpconverters_ShouldNotThrow()
        {
            var arrangements = new Arrangements();

            arrangements.AddUpconverter <Event_V1, Event_V2>();
            arrangements.AddUpconverter <Event_V2, Event_V3>();

            var exception = Record.Exception(() => UpconverterExistsForEventsValidator.CheckIfUpconvertersExistOrThrow(arrangements.EventTypes, t => t == typeof(Event_V1), arrangements.Converters));

            exception.Should().BeNull();
        }
        public void CheckIfUpconvertersExistOrThrow_WithThreEventsWithOnlyOneUpconverter_ShouldThrow()
        {
            var arrangements = new Arrangements();

            arrangements.AddUpconverter <Event_V1, Event_V2>();

            var exception = Record.Exception(() => UpconverterExistsForEventsValidator.CheckIfUpconvertersExistOrThrow(arrangements.EventTypes, t => t == typeof(Event_V1), arrangements.Converters));

            exception.Should().NotBeNull();
            exception.Should().BeOfType <MissingUpconverterException>();
        }
 public bool DeepEquals(DestinyItemTranslationBlockDefinition?other)
 {
     return(other is not null &&
            WeaponPatternIdentifier == other.WeaponPatternIdentifier &&
            WeaponPatternHash == other.WeaponPatternHash &&
            DefaultDyes.DeepEqualsList(other.DefaultDyes) &&
            LockedDyes.DeepEqualsList(other.LockedDyes) &&
            CustomDyes.DeepEqualsList(other.CustomDyes) &&
            Arrangements.DeepEqualsList(other.Arrangements) &&
            HasGeometry == other.HasGeometry);
 }
Example #10
0
 public bool DeepEquals(ArtifactTranslationBlock other)
 {
     return(other != null &&
            Arrangements.DeepEqualsReadOnlyCollections(other.Arrangements) &&
            CustomDyes.DeepEqualsReadOnlyCollections(other.CustomDyes) &&
            DefaultDyes.DeepEqualsReadOnlyCollections(other.DefaultDyes) &&
            LockedDyes.DeepEqualsReadOnlyCollections(other.LockedDyes) &&
            HasGeometry == other.HasGeometry &&
            WeaponPatternHash == other.WeaponPatternHash &&
            WeaponPatternIdentifier == other.WeaponPatternIdentifier);
 }
        public async Task PatchAsJsonAsync_WithNullUri_ThrowsArgumentException()
        {
            //Arrange
            var client = new Arrangements().GetClient();

            //Act
            var exception = await Record.ExceptionAsync(() => client.PatchAsJsonAsync(null, new object()));

            //Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentNullException>();
        }
        public void Upconvert_WithNull_ShouldThrowException()
        {
            // Arrange
            var sut = new Arrangements().BuildAndGetSUT();

            // Act
            var exception = Record.Exception(() => sut.Upconvert(null));

            // Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentNullException>();
        }
Example #13
0
        public void UpdateStock_NullStock_ShouldThrowException()
        {
            // Arrange
            var arrangements = new Arrangements();

            Dictionary <string, int> newStock = null;

            // Act
            var error = Record.Exception(() => arrangements.SUT.Update(newStock));

            // Assert
            error.Should().BeOfType <Exception>();
            error.Message.Should().Be("Catalog list is empty.");
        }
Example #14
0
        private Arrangements GetArrangements()
        {
            var arrangements = new Arrangements()
            {
                Id = Guid.NewGuid().ToString(),
                InnerRepositoryMock = new Mock <IAggregateRepository <UserTriggerAggregate, UserTriggerId> >(),
            };

            arrangements.Sut =
                new CachedAggregateRepository <UserTriggerAggregate, UserTriggerId>(
                    arrangements.InnerRepositoryMock.Object);

            return(arrangements);
        }
        public void Upconvert_WithEmptyInput_ShouldReturnEmptyCollectionAndNotThrow()
        {
            // Arrange
            var sut = new Arrangements().BuildAndGetSUT();
            IEnumerable <ItemWithType> upconverted = null;

            // Act
            var exception = Record.Exception((Action)(() => upconverted = sut.Upconvert(new ItemWithType[0])));

            // Assert
            exception.Should().BeNull();
            upconverted.Should().NotBeNull();
            upconverted.Count().Should().Be(0);
        }
Example #16
0
        public void GetAllItems_ShouldReturnCorrectItems()
        {
            // Arrange
            var arrangements = new Arrangements();

            var catalogItems = new Dictionary <string, int>();

            catalogItems.Add("Macbook", 10);
            catalogItems.Add("iPad", 5);

            // Act
            var result = arrangements.SUT.GetAllItems();

            // Assert
            result.Should().BeEquivalentTo(catalogItems);
        }
Example #17
0
        public void UpdateStock_WithValidStock_ShouldHaveNewStockQauntity()
        {
            // Arrange
            var arrangements = new Arrangements();

            Dictionary <string, int> newStock = new Dictionary <string, int>();

            newStock.Add("Macbook", 3);
            newStock.Add("iPad", 2);

            // Act
            arrangements.SUT.Update(newStock);

            // Assert
            newStock.Should().BeEquivalentTo(arrangements.SUT.GetAllItems());
        }
        public void UpconvertGivenUpconverterAToB_WithEventB_ShouldReturnEventB()
        {
            // Arrange
            var sut = new Arrangements()
                      .AddUpconverter <EventA, EventB>(a => new EventB(a.Name, a.Count))
                      .BuildAndGetSUT();
            var source = new EventB("Mr. Silly Name", 5);

            // Act
            var upconverted = sut.Upconvert(new ItemWithType[] { new ItemWithType(source) });

            // Assert
            upconverted.Should().NotBeNullOrEmpty();
            upconverted.Count().Should().Be(1);
            upconverted.First().type.Should().Be <EventB>();
            ReferenceEquals(upconverted.First().instance, source).Should().BeTrue();
        }
Example #19
0
        public void UpdateStock_InvalidStock_ShouldThrowException()
        {
            // Arrange
            var arrangements = new Arrangements();

            Dictionary <string, int> newStock = new Dictionary <string, int>();

            newStock.Add("Macbook", 3);
            newStock.Add("iPhone", 2);

            // Act
            var error = Record.Exception(() => arrangements.SUT.Update(newStock));

            // Assert
            error.Should().BeOfType <Exception>();
            error.Message.Should().Be("Item on the list is not part of the catalog.");
        }
        public async Task PatchAsJsonAsync_WithValidParams_ShouldMakeAPatchRequestToResource()
        {
            //Arrange
            var arrangements = new Arrangements();
            var payload      = new { Value = 5, Name = "MyName" };

            //Act
            using (arrangements.StartServer())
                using (var client = arrangements.GetClient())
                {
                    await client.PatchAsJsonAsync("capture", payload);
                }

            //Arrange
            var request = arrangements.Requests[0];

            request.Method.Should().BeEquivalentTo("patch");
        }
        public async Task PatchAsJsonAsync_WithValidParams_RequestShouldBeJson()
        {
            //Arrange
            var arrangements = new Arrangements();
            var payload      = new { Value = 5, Name = "MyName" };

            //Act
            using (arrangements.StartServer())
                using (var client = arrangements.GetClient())
                {
                    await client.PatchAsJsonAsync("capture", payload);
                }

            //Arrange
            var request = arrangements.Requests[0];

            request.ContentType.Should().BeEquivalentTo("application/json; charset=utf-8");
        }
        public void UpconvertGivenUpconverterAToBAndUpconvertBToC_WithEventB_ShouldReturnEventC()
        {
            // Arrange
            var sut = new Arrangements()
                      .AddUpconverter <EventA, EventB>(x => new EventB(x.Name, x.Count))
                      .AddUpconverter <EventB, EventC>(x => new EventC(x.Count))
                      .BuildAndGetSUT();
            var source   = new EventB("Mr. Silly Name", 4);
            var expected = new EventC(source.Count);

            // Act
            var upconverted = sut.Upconvert(new ItemWithType[] { new ItemWithType(source) });

            // Assert
            upconverted.Should().NotBeNullOrEmpty();
            upconverted.Count().Should().Be(1);
            upconverted.ToArray()[0].type.Should().Be <EventC>();
            upconverted.ToArray()[0].instance.As <EventC>().Count.Should().Be(expected.Count);
        }
 public void Update(DestinyItemTranslationBlockDefinition?other)
 {
     if (other is null)
     {
         return;
     }
     if (WeaponPatternIdentifier != other.WeaponPatternIdentifier)
     {
         WeaponPatternIdentifier = other.WeaponPatternIdentifier;
         OnPropertyChanged(nameof(WeaponPatternIdentifier));
     }
     if (WeaponPatternHash != other.WeaponPatternHash)
     {
         WeaponPatternHash = other.WeaponPatternHash;
         OnPropertyChanged(nameof(WeaponPatternHash));
     }
     if (!DefaultDyes.DeepEqualsList(other.DefaultDyes))
     {
         DefaultDyes = other.DefaultDyes;
         OnPropertyChanged(nameof(DefaultDyes));
     }
     if (!LockedDyes.DeepEqualsList(other.LockedDyes))
     {
         LockedDyes = other.LockedDyes;
         OnPropertyChanged(nameof(LockedDyes));
     }
     if (!CustomDyes.DeepEqualsList(other.CustomDyes))
     {
         CustomDyes = other.CustomDyes;
         OnPropertyChanged(nameof(CustomDyes));
     }
     if (!Arrangements.DeepEqualsList(other.Arrangements))
     {
         Arrangements = other.Arrangements;
         OnPropertyChanged(nameof(Arrangements));
     }
     if (HasGeometry != other.HasGeometry)
     {
         HasGeometry = other.HasGeometry;
         OnPropertyChanged(nameof(HasGeometry));
     }
 }
        public async Task PatchAsJsonAsync_WithValidParams_ShouldMakeExactlyOneRequestToResource()
        {
            //Arrange
            var arrangements = new Arrangements();
            var payload      = new { Value = 5, Name = "MyName" };

            //Act
            using (arrangements.StartServer())
                using (var client = arrangements.GetClient())
                {
                    await client.PatchAsJsonAsync("capture", payload);
                }

            //Arrange
            arrangements.Requests.Should().NotBeEmpty();
            arrangements.Requests.Count.Should().Be(1);
            var request = arrangements.Requests[0];

            request.Resource.Should().EndWith("capture");
        }
        public async Task PatchAsJsonAsync_WithValidParams_RequestShouldIncludePayload()
        {
            //Arrange
            var arrangements = new Arrangements();
            var payload      = new { Value = 5, Name = "MyName" };

            //Act
            using (arrangements.StartServer())
                using (var client = arrangements.GetClient())
                {
                    await client.PatchAsJsonAsync("capture", payload);
                }

            //Arrange
            var request         = arrangements.Requests[0];
            var receivedPayload = JsonConvert.DeserializeAnonymousType(request.Payload, payload);

            receivedPayload.Value.Should().Be(payload.Value);
            receivedPayload.Name.Should().Be(payload.Name);
        }
        public bool Equals(DestinyItemTranslationBlockDefinition input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     WeaponPatternIdentifier == input.WeaponPatternIdentifier ||
                     (WeaponPatternIdentifier != null && WeaponPatternIdentifier.Equals(input.WeaponPatternIdentifier))
                     ) &&
                 (
                     WeaponPatternHash == input.WeaponPatternHash ||
                     (WeaponPatternHash.Equals(input.WeaponPatternHash))
                 ) &&
                 (
                     DefaultDyes == input.DefaultDyes ||
                     (DefaultDyes != null && DefaultDyes.SequenceEqual(input.DefaultDyes))
                 ) &&
                 (
                     LockedDyes == input.LockedDyes ||
                     (LockedDyes != null && LockedDyes.SequenceEqual(input.LockedDyes))
                 ) &&
                 (
                     CustomDyes == input.CustomDyes ||
                     (CustomDyes != null && CustomDyes.SequenceEqual(input.CustomDyes))
                 ) &&
                 (
                     Arrangements == input.Arrangements ||
                     (Arrangements != null && Arrangements.SequenceEqual(input.Arrangements))
                 ) &&
                 (
                     HasGeometry == input.HasGeometry ||
                     (HasGeometry != null && HasGeometry.Equals(input.HasGeometry))
                 ));
        }
        /// <inheritdoc cref="IArrangementCollection" />
        public bool CanApplyAtLeasOneArrangmentTo(IInvocation invocation)
        {
            Ensures.NotNull(invocation, nameof(invocation));

            return(Arrangements.Any(a => a.CanApplyTo(invocation)));
        }
 /// <summary>
 /// Well, add an arrangement
 /// </summary>
 /// <param name="arrangement">Arrangement to add</param>
 public virtual void AddArrangement(IArrangement arrangement)
 {
     Arrangements.Add(arrangement);
 }
Example #29
0
 public ArrangementsBuilder(IDbConnection dbConnection)
 {
     A = new Arrangements {
         DbConnection = dbConnection
     };
 }
Example #30
0
 public void Setup()
 {
     _arrangements = new Arrangements(32);
 }