Beispiel #1
0
		public void Update_Discs() {

			var contract = new AlbumForEditContract(album, ContentLanguagePreference.English, new InMemoryImagePersister());
			repository.Save(CreateEntry.AlbumDisc(album));

			contract.Discs = new[] {
				new AlbumDiscPropertiesContract { Id = 1, Name = "Past" },
				new AlbumDiscPropertiesContract { Id = 2, Name = "Present" }
			};

			contract = CallUpdate(contract);

			var albumFromRepo = repository.Load(contract.Id);
			Assert.AreEqual(2, albumFromRepo.Discs.Count, "Number of discs");

			var disc1 = albumFromRepo.GetDisc(1);
			Assert.IsNotNull(disc1, "disc1");
			Assert.AreEqual("Past", disc1.Name, "disc1.Name");

			var disc2 = albumFromRepo.GetDisc(2);
			Assert.IsNotNull(disc2, "disc2");
			Assert.AreEqual("Present", disc2.Name, "disc2.Name");

			var archivedVersion = repository.List<ArchivedAlbumVersion>().FirstOrDefault();

			Assert.IsNotNull(archivedVersion, "Archived version was created");
			Assert.AreEqual(AlbumEditableFields.Discs, archivedVersion.Diff.ChangedFields.Value, "Changed fields");

		}
Beispiel #2
0
        public async Task Update_Discs()
        {
            var contract = new AlbumForEditContract(_album, ContentLanguagePreference.English, new InMemoryImagePersister());

            _repository.Save(CreateEntry.AlbumDisc(_album));

            contract.Discs = new[] {
                new AlbumDiscPropertiesContract {
                    Id = 1, Name = "Past"
                },
                new AlbumDiscPropertiesContract {
                    Id = 2, Name = "Present"
                }
            };

            contract = await CallUpdate(contract);

            var albumFromRepo = _repository.Load(contract.Id);

            albumFromRepo.Discs.Count.Should().Be(2, "Number of discs");

            var disc1 = albumFromRepo.GetDisc(1);

            disc1.Should().NotBeNull("disc1");
            disc1.Name.Should().Be("Past", "disc1.Name");

            var disc2 = albumFromRepo.GetDisc(2);

            disc2.Should().NotBeNull("disc2");
            disc2.Name.Should().Be("Present", "disc2.Name");

            var archivedVersion = _repository.List <ArchivedAlbumVersion>().FirstOrDefault();

            archivedVersion.Should().NotBeNull("Archived version was created");
            archivedVersion.Diff.ChangedFields.Value.Should().Be(AlbumEditableFields.Discs, "Changed fields");
        }