public async Task MarkCompleteWhileComplete() { Context.UoW.Plan <Example.Todo.Todo>(Context.Id()) .HasEvent <Example.Todo.Events.Added>(x => { x.TodoId = Context.Id(); x.Message = "test"; }) .HasEvent <Example.Todo.Events.MarkedComplete>(x => { x.TodoId = Context.Id(); }); var command = new Example.Todo.Commands.MarkComplete { TodoId = Context.Id(), }; var ex = await Record.ExceptionAsync(() => Sut.Handle(command, Context)).ConfigureAwait(false); ex.Should().BeOfType <BusinessException>(); }
private async Task <bool> IsFileEquals(Record a, Record b) { await this.AreEqualAsync(a.Id, b.Id); await this.AreEqualAsync(a.FullPath, b.FullPath); await this.AreEqualAsync(a.Directory, b.Directory); await this.AreEqualAsync(a.FileName, b.FileName); await this.AreEqualAsync(a.DateModified, b.DateModified); await this.AreEqualAsync(a.DateCreated, b.DateCreated); await this.AreEqualAsync(a.DateRegistered, b.DateRegistered); await this.AreEqualAsync(a.Width, b.Width); await this.AreEqualAsync(a.Height, b.Height); await this.AreEqualAsync(a.Size, b.Size); return(await IsFileOptionsEquals(a, b)); }
private static bool Compare(Dictionary <Key, Record> recs1, Dictionary <Key, Record> recs2) { Log.Info("Comparing records"); if (!CheckKeys(recs1, recs2)) { return(false); } bool ok = true; var lookup = new Dictionary <Key, Key>(); foreach (Key key in recs1.Keys) { lookup[key] = key; } foreach (Key key2 in recs2.Keys) { Key key1 = lookup[key2]; if ((key1.userKey == null) != (key2.userKey == null)) { Log.Error("User key mismatch [1] for key {0}", key1); ok = false; } if (key1.userKey != null) { byte[] keyBlob1 = ValueToBlob(key1.userKey); byte[] keyBlob2 = ValueToBlob(key2.userKey); if (!keyBlob1.SequenceEqual(keyBlob2)) { Log.Error("User key mismatch [2] for key {0}", key1); ok = false; } } } foreach (Key key in recs1.Keys) { Record rec1 = recs1[key]; Record rec2 = recs2[key]; int expDiff = rec1.expiration - rec2.expiration; if (expDiff < -3 || expDiff > 3) { Log.Error("Expiration mismatch for key {0}: {1} vs. {2}", key, rec1.expiration, rec2.expiration); ok = false; } if (!CheckKeys(rec1.bins, rec2.bins)) { ok = false; continue; } foreach (string name in rec1.bins.Keys) { byte[] recBlob1 = ObjectToBlob(rec1.bins[name]); byte[] recBlob2 = ObjectToBlob(rec2.bins[name]); if (!recBlob1.SequenceEqual(recBlob2)) { Log.Error("Data mismatch for key {0}, bin {1}", key, name); ok = false; } } } return(ok); }
private async Task <bool> IsFileOptionsEquals(Record a, Record b, bool differentThumbnail = false) { await this.AreEqualAsync(a.TagEntry, b.TagEntry); Assert.IsTrue(a.TagSet.Read().OrderBy(x => x).SequenceEqual (b.TagSet.Read().OrderBy(x => x), (x, y) => x.Equals(y))); await this.AreEqualAsync( a.TagSet.Read().Select(x => x.ToString()).OrderBy(x => x).Join(";"), b.TagSet.Read().Select(x => x.ToString()).OrderBy(x => x).Join(";")); await this.AreEqualAsync(a.Rating, b.Rating); //await this.AreEqualAsync(a.IsLeader, b.IsLeader); if (differentThumbnail) { await this.AreNotEqualAsync(a.GroupKey, b.GroupKey); } else { await this.AreEqualAsync(a.GroupKey, b.GroupKey); } if (a.GetSort() == null) { Assert.IsNull(b.GetSort()); } else { Assert.IsTrue(a.GetSort().SequenceEqual (b.GetSort(), (x, y) => x.ValueEquals(y))); } await this.AreEqualAsync(a.SortEntry, b.SortEntry); //await this.AreEqualAsync(a.IsParticularFlipDirectionEnabled, b.IsParticularFlipDirectionEnabled); //await this.AreEqualAsync(a.IsFlipReversed, b.IsFlipReversed); await this.AreEqualAsync(a.FlipDirection, b.FlipDirection); await this.AreEqualAsync(a.IsGroup, b.IsGroup); await this.AreEqualAsync(a.PreNameLong, b.PreNameLong); await this.AreEqualAsync(a.PostNameShort, b.PostNameShort); await this.AreEqualAsync(a.NameNumberRight, b.NameNumberRight); await this.AreEqualAsync(a.PreNameShort, b.PreNameShort); await this.AreEqualAsync(a.PostNameLong, b.PostNameLong); await this.AreEqualAsync(a.NameNumberLeft, b.NameNumberLeft); await this.AreEqualAsync(a.Extension, b.Extension); await this.AreEqualAsync(a.NameLength, b.NameLength); return(true); }