public async Task DeleteShouldSucceed() { // Arrange var id = Guid.NewGuid(); var name = "nameOne"; var nameOnApplication = "nameOnApplication"; var description = "description"; var icon = new RemarkIcon(Guid.NewGuid()); var defaultRemark = new DefaultRemark("defaultRemark1"); var defaultRemarks = new List <DefaultRemark>() { defaultRemark }; var tags = new List <Tag>(); var remark = RepositoryHelper.ForRemark.CreateRemark(id, name, nameOnApplication, description, icon, defaultRemarks, tags); // Act await _repository.DeleteAsync(id, 0); // Assert var data = RepositoryHelper.ForRemark.GetRemarks(); data.Should().HaveCount(0); }
public async Task UpdateShouldSucceed() { // Arrange var id = Guid.NewGuid(); var name = "name"; var nameOnApplication = "nameOnApplication"; var description = "description"; var icon = new RemarkIcon(Guid.NewGuid()); var defaultRemark = new DefaultRemark("defaultRemark1"); var defaultRemarks = new List <DefaultRemark>() { defaultRemark }; var tags = new List <Tag>(); var remark = RepositoryHelper.ForRemark.CreateRemark(id, name, nameOnApplication, description, icon, defaultRemarks, tags); var tag = new Tag("tag1"); remark.AddTag(tag); // Act await _repository.UpdateAsync(remark); // Assert var data = RepositoryHelper.ForRemark.GetRemarks(); data.Should().HaveCount(1); var result = data.First(); result.Should().NotBeNull(); result.Tags.Should().HaveCount(1); result.Tags.First().Should().Be(tag); }
public void AddDefaultRemarkShouldSucceed() { // Arrange var entity = new Remark(id, name, nameOnApplication, description, icon); var defaultRemark = new DefaultRemark(Guid.NewGuid().ToString()); // Act entity.AddDefaultRemark(defaultRemark); // Assert entity.DefaultRemarks.Count.Should().Be(1); entity.DefaultRemarks.ElementAt(0).Should().Be(defaultRemark); }
public void RemoveUnexistingDefaultRemarkShouldPassSilentlyWithoutAnyImpactOnCollection() { // Arrange var entity = new Remark(id, name, nameOnApplication, description, icon); var defaultRemark = new DefaultRemark(Guid.NewGuid().ToString()); entity.AddDefaultRemark(defaultRemark); var defaultRemarkToRemove = new DefaultRemark(Guid.NewGuid().ToString()); // Act entity.RemoveDefaultRemark(defaultRemarkToRemove); // Assert entity.DefaultRemarks.Count.Should().Be(1); entity.DefaultRemarks.ElementAt(0).Should().Be(defaultRemark); }
public async Task CreateShouldSuccess() { // Arrange var id = Guid.NewGuid(); var name = "name"; var nameOnApplication = "nameOnApplication"; var description = "description"; var icon = new RemarkIcon(Guid.NewGuid()); var defaultRemark = new DefaultRemark("defaultRemark1"); var defaultRemarks = new List <DefaultRemark>() { defaultRemark }; var tag = new Tag("tag1"); var tags = new List <Tag>() { tag }; var remark = new Remark(id, name, nameOnApplication, description, icon); defaultRemarks.ForEach(x => remark.AddDefaultRemark(x)); tags.ForEach(x => remark.AddTag(x)); // Act await _repository.CreateAsync(remark); // Assert var data = RepositoryHelper.ForRemark.GetRemarks(); data.Should().HaveCount(1); var result = data.First(); result.Name.Should().Be(name); result.NameOnApplication.Should().Be(nameOnApplication); result.Description.Should().Be(description); result.Icon.Should().Be(icon); result.DefaultRemarks.Should().HaveCount(1); result.DefaultRemarks.First().Should().Be(defaultRemark); result.Tags.Should().HaveCount(1); result.Tags.First().Should().Be(tag); }
public void CreateWithAlreadyExistingNameShouldFail() { // Arrange var id = Guid.NewGuid(); var name = "name"; var nameOnApplication = "nameOnApplication"; var description = "description"; var icon = new RemarkIcon(Guid.NewGuid()); var defaultRemark = new DefaultRemark("defaultRemark1"); var defaultRemarks = new List <DefaultRemark>() { defaultRemark }; var tag = new Tag("tag1"); var tags = new List <Tag>() { tag }; RepositoryHelper.ForRemark.CreateRemark(id, name, nameOnApplication, description, icon, defaultRemarks, tags); var otherId = Guid.NewGuid(); var otherName = name; var otherNameOnApplication = "nameOnApplication"; var otherDescription = "description"; var otherIcon = new RemarkIcon(Guid.NewGuid()); var remark = new Remark(otherId, otherName, otherNameOnApplication, otherDescription, otherIcon); // Act Action act = () => { _repository.CreateAsync(remark).GetAwaiter().GetResult(); }; // Assert act.Should().Throw <UniqueKeyException>(); }