public void ChangeDemoDir(string fileName) { const string newDir = "sussy baka uwu"; var before = GetDemo(fileName); MemoryStream outStream = new MemoryStream(); OptChangeDemoDir.ChangeDemoDir(before, outStream, newDir); SourceDemo after = new SourceDemo(outStream.ToArray()); after.Parse(); // check that all the packets are unchanged CollectionAssert.AreEqual( before.Frames.Select(frame => frame.Type), after.Frames.Select(frame => frame.Type)); // check that all messages are unchanged CollectionAssert.AreEqual( before.FilterForMessages().Select(t => t.messageType), after.FilterForMessages().Select(t => t.messageType)); // check that the new demo has the new dir in header and SvcServerInfo messages Assert.AreEqual(after.Header.GameDirectory, newDir); Assert.That(after.FilterForMessage <SvcServerInfo>().Select(t => t.message.GameDir), Is.All.EqualTo(newDir)); }
public void RemoveCaptions(string fileName) { var before = GetDemo(fileName); MemoryStream outStream = new MemoryStream(); OptRemoveCaptions.RemoveCaptions(before, outStream); SourceDemo after = new SourceDemo(outStream.ToArray()); after.Parse(); // check that the new demo doesn't have captions CollectionAssert.IsEmpty(after.FilterForUserMessage <CloseCaption>()); // check that all the packets are unchanged CollectionAssert.AreEqual( before.Frames.Select(frame => frame.Type), after.Frames.Select(frame => frame.Type)); // check that all the non-caption and non-nop messages are unchanged CollectionAssert.AreEqual( before.FilterForMessages().Where(tuple => tuple.messageType != MessageType.NetNop) .Where(tuple => (tuple.message as SvcUserMessage)?.MessageType != UserMessageType.CloseCaption) .Select(tuple => tuple.messageType), after.FilterForMessages().Where(tuple => tuple.messageType != MessageType.NetNop) .Select(tuple => tuple.messageType) ); }