I'm making a change to the TCR script. I've started to pause the script to extract a class instead of doing the 1/2 dozen steps to make it move. I don't like pausing the script.
BUT... I also get really annoyed at the steps I have to take. And I realized something - The steps aren't the issue, the pausing isn't the issue - the script is triggering on something that it shouldn't.
The script shouldn't trigger on file creation.
Probably shouldn't trigger on delete either.
Changed is probably the only one it should trigger on.
I'm gonna change to that and see how it feels.
More Adapter
I'm working on the scribe adapter...
OK, not happy with the Foo
method I added to the interface. Not sure why I did that. ... OHHHH... the analyzers complain about empty interfaces. I accept.
OK... I have the CosmosItemResponse
object... For this, I'm going to ALSO need... and I could fake it... but gonna need to make the ItemResponseCosmosItemResponse
...
OK... I think I understand my previouis naming. The item Cosmos gives back is an ItemResponse
. My other code has the returned class called CosmosResponse
.
I can't control the ItemResponse
class name; but I can definitely control my response objects class name... Gonna think about this a moment.
I... like, but can't use ItemResponse
. I see why I went with CosmosResponse
. ANYTHING else is ... noise.
OK, gonna rename it from CosmosItemResponse
to ... Can I just do Response<T>
? OperationResponse
? OpResponse
? I'm considering the Upsert, Delete, Query, PointRead as 'Operations' to ...
I'll try OpResponse
. Then, the item the Scribe will return will be ItemResponseOpResponse
... Or... just ItemOpResponse
. OK... I can handle that.
ummm..... I saved the files... and nothing triggered...
HUH... when I save, it triggers as a "Rename"... apparently that's normal... neat.
OK... NOW let's rename the class...
It didn't detect the changes properly. Had to save afterwords to get the script to run and tests pass.
I'm gonna sleep the start of the test runner for 1/2 a second to give all the file changes a change to process.
Renames might just be a bit funny with the script as is.
ANYWAY... onto the ItemOpResponse
.
I am making it's Should_Exist
test pretty extensive
[TestMethod, TestCategory("unit")]
public void Should_Exist()
{
//arrange
//act
OpResponse<object> actual = new ItemOpResponse<object>(new ItemResponseFake() as ItemResponse<object>);
//assert
}
It'll help avoid some re-test in the future.
Got all this
public sealed class ItemOpResponse<T> : OpResponse<T>
{
public ItemOpResponse(ItemResponse<T> itemResponse)
{
}
public override T Value => throw new System.NotImplementedException();
public override HttpStatusCode StatusCode => throw new System.NotImplementedException();
}
I wonder if I can move it with the update to the TCR script... which is what I wanted to update the script to enable... WE'LL SEEEEEEEE..... HAHA - no trigger.
Save the test file and BAM - worked.
... Random Aside
Jay and Llewellyn did a presentation at AONW 2025 talking about their disagreements of Arlo's Commit Notation. One of those disagreements was the indicator of a 'Validated' change. The git repo has that indicator being ^
and... One of them; I THINK Jay; like -
better. I think it was -
. I didn't care, I was happy to use the ^
. Until I had to actually use it as speed. The way my hands sit on the keyboard; split/tented; I am JUST a smidge shy of being able to hit "LEFT SHIFT + 6" easily. As such... I'm using -
, which I can hit easy. Yeah... I'm lazy.
"wHy NOt tHE riGHt ShiFT?" - Because I hit the left shift. That's why. Right shift could be disabled and I probably wouldn't know for a month or more. Soooo... I'm a lazy fucker and I'm using -
because of that.
HAHAHA - I copy/pasted the test. Did NOT follow the Woody Zuill approach to updating a copy/paste test; which is from the bottom up; rename the method last. I forgot to change the assertion. So I updated the code; tests ran - got the sad beep and watch the changes vanish before my eyes.
I want to stay it's not much different than if the revert didn't happen... but it's SO MUCH DIFFERENT. There's a visceral feeling when the code POOFs away. I don't want that. If I don't have the revert; it's just "haha, doh, let's fix and continue". A VERY TINY inconvience. I don't have to care as much or pay as much attention. There's zero cost to not getting the test right.
With TCR... oh; you don't get the test right - you have to re-implement the functionality.
YEAH YEAH - it's a few seconds of typing. the REAL cost is trivial, but the psychological impact of "gotta do it again" ... I'm getting a much stronger feeling abvout not wanting my tests to be wrong.
Also... not triangulating like I should. I thought about doing this in a "TDD, like I mean it" style... but I think with TCR as the primary focus, that one is getting dropped.
And with that; ItemOpResponse
is complete...
CAN I NOW CODE THE UPSERT?! I think I've been trying for 3 nights... I've been doing this for a couple hours now. Which seems like it's taking forever for me to get any code written... I'm also writing the blog... and fixing the script... but still...
One of these nights I'll do a summary blog and just let loose on TDD/TCR with the code.
Tonight is not that night. ... but I can finally get the CosmosContainerUpsertAdapter
written.
The simple test - make it upsert
[TestMethod, TestCategory("unit")]
public void UpsertItemAsync_ShouldCallUpsertItemAsyncOnContainer()
{
//arrange
//act
//assert
}
Apparently I'm also dropping the METHOD_exists
tests... sometimes? hehe
Look; I'm TCRing, TDDing, and getting some code written. We can slack a little on THE STRICTEST I KNOW. For now anyway.
...
I had a few hiccups. Getting some stuff into place... I cheated. :(
But it exsits now
public sealed class CosmosContainerUpsertAdapter : ICosmosContainerUpsertAdapter
{
private readonly ILogger _logger;
public CosmosContainerUpsertAdapter(ILogger logger)
{
_logger = logger;
}
public async Task<OpResponse<T>> UpsertItemAsync<T>(Container container, T item)
{
ItemResponse<T> itemResponse = await container.UpsertItemAsync(item).ConfigureAwait(false);
_logger.UpsertInformation(itemResponse.RequestCharge, itemResponse.Diagnostics.GetClientElapsedTime());
return new ItemOpResponse<T>(itemResponse);
}
}
public static partial class CosmosContainerUpsertAdapterLoggerExtensions
{
[LoggerMessage(
Level = LogLevel.Information,
Message = "UpsertItem cost: [RequestCharge={requestCharge}] [ElapsedTime={elapsedTime}]")
]
public static partial void UpsertInformation(this ILogger logger, double requestCharge, TimeSpan elapsedTime);
}
I bet I could fancy pants some regex and extract out the error messages for failing tests... the point of TCR is that, noooo, you just try again. I was fucking up hard enough I paused it to figure out what dumb I was doing.
I also kipped straight to the LoggerMessage
functionality. I SHOULD have implemented it on logger then extracted it as a refactor. but... did not.
I paused the script and moved files all around.