Skip to content

Commit

Permalink
chore: Add UpdatedTypes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed May 9, 2024
1 parent 581a7d7 commit ad90515
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ internal class UpdateDelta
public string ModuleId { get; set; } = default!;
public string MetadataDelta { get; set; } = default!;
public string ILDelta { get; set; } = default!;
public int[]? UpdatedTypes { get; set; } = default!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public async Task DeltasAreSavedOnPost()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
context.Request.Body = GetJson(deltas);
Expand All @@ -56,13 +58,15 @@ public async Task DuplicateDeltasOnPostAreIgnored()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
var context = new DefaultHttpContext();
Expand Down Expand Up @@ -97,13 +101,15 @@ public async Task MultipleDeltaPayloadsCanBeAccepted()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
var context = new DefaultHttpContext();
Expand All @@ -124,20 +130,23 @@ public async Task MultipleDeltaPayloadsCanBeAccepted()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta3",
MetadataDelta = "MetadataDelta3",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 4,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta4",
MetadataDelta = "MetadataDelta4",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 5,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta5",
MetadataDelta = "MetadataDelta5",
UpdatedTypes = [42],
},
};

Expand Down Expand Up @@ -184,13 +193,15 @@ public async Task GetReturnsDeltas()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
middleware.Deltas.AddRange(deltas);
Expand Down Expand Up @@ -221,13 +232,15 @@ public async Task GetReturnsNotModified_IfNoneMatchApplies()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
middleware.Deltas.AddRange(deltas);
Expand Down Expand Up @@ -262,13 +275,15 @@ public async Task GetReturnsUpdatedResults_IfNoneMatchFails()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta1",
MetadataDelta = "MetadataDelta1",
UpdatedTypes = [42],
},
new BlazorWasmHotReloadMiddleware.UpdateDelta
{
SequenceId = 1,
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta2",
MetadataDelta = "MetadataDelta2",
UpdatedTypes = [42],
}
};
middleware.Deltas.AddRange(deltas);
Expand All @@ -284,6 +299,7 @@ public async Task GetReturnsUpdatedResults_IfNoneMatchFails()
ModuleId = Guid.NewGuid().ToString(),
ILDelta = "ILDelta3",
MetadataDelta = "MetadataDelta3",
UpdatedTypes = [42],
};
deltas.Add(update);
middleware.Deltas.Add(update);
Expand Down Expand Up @@ -313,6 +329,7 @@ private static void AssertDeltas(IReadOnlyList<BlazorWasmHotReloadMiddleware.Upd
Assert.Equal(expected[i].MetadataDelta, actual[i].MetadataDelta);
Assert.Equal(expected[i].ModuleId, actual[i].ModuleId);
Assert.Equal(expected[i].SequenceId, actual[i].SequenceId);
Assert.Equal(expected[i].UpdatedTypes, actual[i].UpdatedTypes);
}
}

Expand Down

0 comments on commit ad90515

Please sign in to comment.