public void NetworkBehaviourCmdParamComponent() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for component type MirrorTest.MirrorTestPlayer/ComponentClass. Use a supported type or provide a custom writer")); }
public void TestRest() { Assert.Contains("a", new[] { "a", "b" }); Assert.That(new[] { "a", "b" }, Contains.Item("a")); Assert.That(new[] { "a", "b" }, Does.Contain("b")); }
public async Task ProcessJobsForMyDataCenter_XInQueueWithYConsumers_TakeNextApproach(int numberOfJobsToQueue, int numberOfConsumers) { var testStartTime = DateTime.Now; var exampleQueueName = QueueId.Parse("ExampleQueue"); await RunInMongoLand(async database => { // Create two jobs that are relevant for my datacenter var creationService = new MongoJobCreationService(database); var jobsInQueue = new List <JobId>(); var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < numberOfJobsToQueue; i++) { var newJobId = await creationService.Create(exampleQueueName, new JobAttributes { { "Name", "SpinWidget" }, { "DataCenter", "CAL01" }, }).ConfigureAwait(false); jobsInQueue.Add(newJobId); } stopwatch.Stop(); Console.WriteLine($"Creating {numberOfJobsToQueue} jobs took: {stopwatch.ElapsedMilliseconds} ms"); var finishedJobs = new ConcurrentBag <Job>(); var cancellationSource = new CancellationTokenSource(); cancellationSource.CancelAfter(MaxTestTime); var cancellationToken = cancellationSource.Token; stopwatch.Reset(); stopwatch.Start(); for (int i = 0; i < numberOfConsumers; i++) { var myDataCenter = new JobAttributes { { "DataCenter", "CAL01" } }; await SetupTakeNextWorkerWithSubscription(database, exampleQueueName, finishedJobs, myDataCenter, cancellationToken).ConfigureAwait(false); } do { Thread.Sleep(100); } while (finishedJobs.Count < jobsInQueue.Count && DateTime.Now < testStartTime.Add(MaxTestTime)); stopwatch.Stop(); Console.WriteLine($"{numberOfConsumers} consumers processed {numberOfJobsToQueue} jobs in: {stopwatch.ElapsedMilliseconds} ms"); cancellationSource.Cancel(); var finishedJobIds = finishedJobs.Select(x => x.Id).ToList(); foreach (var jobId in jobsInQueue) { Assert.That(finishedJobIds, Contains.Item(jobId)); } }).ConfigureAwait(false); }
public void GotMissingInputWarnings() { Assert.That(_messages, Contains.Item("No input row found for block 2 of page 2")); Assert.That(_messages, Contains.Item("No input found for pages from 4 onwards.")); }
void AssertMessageIsLogged(string expectedMessage) { List <string> messages = messagesLogged.Select(m => m.ToString()).ToList(); Assert.That(messages, Contains.Item(expectedMessage)); }
public void RecursionCount() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/Potato1 can't be serialized because it references itself")); }
public void GotMissingBlockWarning() { Assert.That(_messages, Contains.Item("Input has 3 row(s) for page 2, but page 2 has only 1 place(s) for text")); Assert.That(_messages, Contains.Item("Input has 3 row(s) for page 5, but page 5 has only 2 place(s) for text")); }
public void TargetRpcCantBeStatic() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::TargetCantBeStatic(Mirror.NetworkConnection) must not be static")); }
public void SyncEventStartsWithEvent() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MySyncEventDelegate MirrorTest.MirrorTestPlayer::DoCoolThingsWithExcitingPeople must start with Event. Consider renaming it to EventDoCoolThingsWithExcitingPeople")); }
public void ClientRpcStartsWithRpc() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::DoesntStartWithRpc() must start with Rpc. Consider renaming it to RpcDoesntStartWithRpc")); }
public void TargetRpcStartsWithTarget() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::DoesntStartWithTarget(Mirror.NetworkConnection) must start with Target. Consider renaming it to TargetDoesntStartWithTarget")); }
public void CommandCantBeStatic() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::CmdCantBeStatic() cannot be static")); }
public void NetworkBehaviourCmdDuplicateName() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Duplicate Command name [MirrorTest.MirrorTestPlayer:CmdCantHaveSameName]")); }
public void NetworkBehaviourCmdParamNetworkConnection() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::CmdCantHaveParamOptional(Mirror.NetworkConnection) has invalid parameer monkeyCon. Cannot pass NeworkConnections")); }
public void MessageMemberGeneric() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for generic type MirrorTest.HasGeneric`1<System.Int32>. Use a concrete type or provide a custom writer")); }
public void SyncEventParamGeneric() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/MySyncEventDelegate`1<System.Int32> MirrorTest.MirrorTestPlayer::EventDoCoolThingsWithExcitingPeople must not have generic parameters. Consider creating a new class that inherits from MirrorTest.MirrorTestPlayer/MySyncEventDelegate`1<System.Int32> instead")); }
public void MessageMemberInterface() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Cannot generate writer for interface MirrorTest.SuperCoolInterface. Use a concrete type or provide a custom writer")); }
public void MonoBehaviourSyncVar() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [SyncVar] System.Int32 MirrorTest.MirrorTestPlayer::potato must be inside a NetworkBehaviour. MirrorTest.MirrorTestPlayer is not a NetworkBehaviour")); }
public void GotMissingInputWarning() { Assert.That(_messages, Contains.Item("No input row found for block 2 of page 1")); }
public void MonoBehaviourSyncList() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: Mirror.SyncListInt MirrorTest.MirrorTestPlayer::potato is a SyncObject and must be inside a NetworkBehaviour. MirrorTest.MirrorTestPlayer is not a NetworkBehaviour")); }
public void GotMissingPagesWarning() { Assert.That(_messages, Contains.Item("Input has rows for page 3, but document has no page 3 that can hold text")); Assert.That(_messages, Contains.Item("Input has rows for page 4, but document has no page 4 that can hold text")); Assert.That(_messages, Contains.Item("Input has rows for page 6, but document has no page 6 that can hold text")); }
public void MonoBehaviourTargetRpc() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [TargetRpc] System.Void MirrorTest.MirrorTestPlayer::TargetThisCantBeOutsideNetworkBehaviour(Mirror.NetworkConnection) must be declared inside a NetworkBehaviour")); }
public void WaitEvent() { var pA = _cpu.CurrentProcess; Instructions.Movi(_cpu, Register.A, 1); Instructions.WaitEvent(_cpu, Register.A); Assert.That(_cpu.CurrentProcess, Is.Null); Assert.That(_cpu.DeviceQueue.Where(x => x.DeviceId == DeviceId.Event1).Select(x => x.Process), Contains.Item(pA)); }
public void MonoBehaviourClientCallback() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: [ClientCallback] System.Void MirrorTest.MirrorTestPlayer::ThisCantBeOutsideNetworkBehaviour() must be declared inside a NetworkBehaviour")); }
public void PreferredLocalizations() { string [] locz = main.PreferredLocalizations; Assert.That(locz.Length, Is.GreaterThanOrEqualTo(1), "Length"); Assert.That(locz, Contains.Item("Base"), "Base"); }
public void MessageSelfReferencing() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.PrefabClone has field $MirrorTest.PrefabClone MirrorTest.PrefabClone::selfReference that references itself")); }
private static Task SetupPeekThenAckWorkerWithSubscription(IMongoDatabase database, QueueId queueName, ConcurrentBag <Job> finishedJobs, JobAttributes attributesThatShouldWork, CancellationToken cancellationToken) { var standardAck = new JobAcknowledgment { { "RunnerId", Guid.NewGuid().ToString("N") } }; var options = new PeekNextSubscriptionOptions() { Token = cancellationToken, PeekNextOptions = new PeekNextOptions { QueueId = queueName, HasAttributes = attributesThatShouldWork } }; var subscriber = new TaskBasedPeekNextSubscriber(new MongoJobPeekNextService(new MongoJobQueryService(database))); return(subscriber.Subscribe(async nextJobs => { var nextJob = nextJobs.First(); // Acknowledge the job var acknowledgmentService = new MongoJobAcknowledgmentService(database); var ackResult = await acknowledgmentService.Ack(queueName, nextJob.Id, standardAck).ConfigureAwait(false); if (!ackResult.Success) { return; } var exampleReportMessage1 = "FooBar"; var exampleReportMessage2 = "WizBang"; var exampleReportMessage3 = "PowPop"; // Send Reports var reportService = new MongoJobReportService(database); await reportService.AddReport(queueName, nextJob.Id, new JobReport { { "Timestamp", DateTime.UtcNow.ToString("O") }, { "Message", exampleReportMessage1 } }).ConfigureAwait(false); await reportService.AddReport(queueName, nextJob.Id, new JobReport { { "Timestamp", DateTime.UtcNow.ToString("O") }, { "Message", exampleReportMessage2 } }).ConfigureAwait(false); await reportService.AddReport(queueName, nextJob.Id, new JobReport { { "Timestamp", DateTime.UtcNow.ToString("O") }, { "Message", exampleReportMessage3 } }).ConfigureAwait(false); // Send Result var completionService = new MongoJobCompletionService(database); await completionService.Complete(queueName, nextJob.Id, new JobResult { { "Result", "Success" } }).ConfigureAwait(false); // Finish Job var finishedJobFromDb = await database.GetJobCollection().Find(Builders <Job> .Filter.Eq(x => x.Id, nextJob.Id)).FirstAsync(cancellationToken).ConfigureAwait(false); Assert.That(finishedJobFromDb, Is.Not.Null); Assert.That(finishedJobFromDb.Acknowledgment, Is.Not.Null); Assert.That(finishedJobFromDb.Reports, Has.Length.EqualTo(3)); var valuesOfReports = finishedJobFromDb.Reports.SelectMany(x => x.Values).ToList(); Assert.That(valuesOfReports, Contains.Item(exampleReportMessage1)); Assert.That(valuesOfReports, Contains.Item(exampleReportMessage2)); Assert.That(valuesOfReports, Contains.Item(exampleReportMessage3)); Assert.That(finishedJobFromDb.Result, Is.Not.Null); finishedJobs.Add(finishedJobFromDb); }, options)); }
public void MessageInvalidDeserializeFieldType() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.AccessViolationException is not a supported type")); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.AccessViolationException MirrorTest.PrefabClone::invalidField has unsupported type")); }
public void TakesOnlyNameOfFullyQualifiedAssemblyName() { CsProj project = GetProject("FQAssemblyName"); Assert.That(project.ReferencedAssemblyNames, Contains.Item("NHibernate")); }
public void NetworkBehaviourCmdParamAbstract() { Assert.That(CompilationFinishedHook.WeaveFailed, Is.True); Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: MirrorTest.MirrorTestPlayer/AbstractClass can't be deserialized bcause i has no default constructor")); }