Looking for a particular branch, and git branch -a
returns a LOT of branches?
If on Windows, you could use the Search feature in cmder (you’re using cmder, right?)
Or on mac, cmd+f
and then search the outputted text…
OR you could use one of these two approaches:
1)
git branch
takes a --list
argument , which in turn takes a search arg.
Example:
git branch -a --list *something*
Will return only the branches containing the word “something” (note the wildcard character)
2)
The alternative, if in bash / bash compatible terminal (git bash / cmder etc… on Windows – normal Command Prompt won’t work – unless you’ve got bash extensions installed) is to pipe the result to grep:
git branch -a | grep something
Both methods here will yield the same results.
Side note:
-a
shows all local and remote branches
-r
shows only remote branches
color-themes.com according to it’s description, offers “Color themes for IntelliJ IDEA, Webstorm, PyCharm, RubyMine, PhpStorm and AppCode”
However, it turns out that these themes also work with Rider.
After downloading it (it’s a .jar file) go to File > Import Settings
Choose the downloaded .jar file, and it will import the colour theme.
Once Rider restarts, the theme will be available, and your editor will have switched to that theme
Important:
Unlike Visual Studio, there’s actually two places the colours are configured.
One, is Appearance > Theme:
This governs how the application looks (not how your fonts look)
Light, or Dark (Darcula)
To change the font colours / style, you’ll need to go to Editor > Colors & Fonts > Font
You can then select the Scheme
Notice ‘Solarized Dark’ is now in that list
My preference, however, is the Visual Studio Dark theme (coming from a Windows VS background!)
Full blog post is coming soon.
For now, please see GitHub repository for demo project:
https://github.com/alexjamesbrown/LEDS_Stack
Talk slides at:
http://bit.ly/leds_stack_slides
While developing an Azure Function application, using this tutorial, I encountered a problem.
Ultimately, using func new
generated my function (the run.csx file) which looked like this:
1 2 3 4 |
public static void Run(string mySbMsg, TraceWriter log) { log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}"); } |
Side note: the
mySbMsg
is important – it’s defined in the function.json bindings, and must match.
However, there was a problem.
When sending messages to my topic, they weren’t being picked up by my function.
I was using some very simplistic code to send messages to my topic:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
var topicName = "dev-customer-events"; var serviceBusConnectionString = "Endpoint=sb://....."; var topicClient = new TopicClient(serviceBusConnectionString, topicName); var thing = new { Title = "Hello" }; var json = JsonConvert.SerializeObject(thing, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); var message = new Message(Encoding.ASCII.GetBytes(json)) { //without this, was getting following exception: // Batching brokered messages with distinct SessionId, PartitionKey, or MessageId // is not supported for an entity with partitioning and duplicate detection enabled. MessageId = Guid.NewGuid().ToString() }; await _topicClient.SendAsync(message); |
The messages were definitely being delievered to the topic – I could see that in the Azure portal.
However, the function wasn’t picking them up.
The issue was around the string mySbMsg
parameter.
The scaffolding assumed that it would be a string – but it is in fact, a byte[]
(due to me serializing the JSON)
Changing this parameter to be a byte[] – and my messages are now received by my locally running function.
More often than not, I want to assert that my dependency has been called with a parameter that matches more than one condition.
Let’s say we have a method that calls ICustomerService.Add method.
We want to assert the Add method was called with a Customer that matches a few conditions.
The way we’d typically achieve this is by doing something like this:
1 2 3 4 5 6 7 8 9 10 |
var fake = A.Fake<ICustomerService>(); A.CallTo(() => fake.AddCustomer( A<Customer>.That.Matches(c => c.Property == "123" && c.OtherProperty == "345" && c.AnotherProperty == "456" && c.YetAnotherProperty == "567" ) )).MustHaveHappened(); |
This will work. And it will indeed assert that the AddCustomer method was called with a Customer object, with those properties set to the corresponding values.
The problem lies if one of those properties doesn’t match.
We get a failed test. But no idication of which property it’s failed on.
What I like to do instead, is follow this pattern:
1 2 3 4 5 6 7 8 9 10 |
Customer addedCustomer; A.CallTo(() => a.Add(A<Customer>._)) .Invokes(c => addedCustomer = c.GetArgument<Customer>(0)); //Individual Asserts on addedCustomer Assert.AreEqual("123", addedCustomer.Property); Assert.AreEqual("345", addedCustomer.OtherProperty); Assert.AreEqual("456", addedCustomer.AnotherProperty); Assert.AreEqual("567", addedCustomer.YetAnotherProperty); |
So, here, we’re basically saying when Add is called, with any Customer object, Invoke the anonymous function, that takes the Customer argument, and stores it in addedCustomer.
We can then individually assert on each property.
Note
I created an issue on GitHub which addresses this, with a view to finding a more ‘inline’ solution