Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
shell: pwsh
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NUGET_TOKEN: ${{ secrets.NugetKey }}
- name: Add artifacts
uses: actions/upload-artifact@v1
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,6 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
/src/.vs/Slack.Webhooks/v15/Server/sqlite3
src/.vscode
/.vs
.idea
24 changes: 6 additions & 18 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ Task("Pack")
.IsDependentOn("Build")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings {
Version = gitVersion.NuGetVersionV2,
OutputDirectory = "./artifacts"
};

NuGetPack("src/Slack.Webhooks/Slack.Webhooks.nuspec", nuGetPackSettings);
DotNetCorePack("src/Slack.Webhooks.sln", new DotNetCorePackSettings {
Configuration = configuration,
NoBuild = true,
OutputDirectory = "./artifacts",
ArgumentCustomization = args => args.Append($"-p:PackageVersion={gitVersion.NuGetVersionV2}")
Copy link
Contributor

@jchannon jchannon Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might also have edit/delete the Version task as that won't be updating AssemblyInfo any more. Might have to set UpdateAssemblyInfo = false but I assume it still will calculate the correct version number. Not sure how it does that. I know MinVer will use git tags and/or do a count of commits since the last git tag to give you 1.0.56 for example. UPDATE Looks to work the same way https://gitversion.net/docs/examples

});

if(isGitHubAction)
{
Expand Down Expand Up @@ -140,20 +140,8 @@ Task("DeployNuGet")
});

Task("Test")
.IsDependentOn("TestFramework")
.IsDependentOn("TestCore");

Task("TestFramework")
.IsDependentOn("Build")
.Does(() =>
{
var testAssemblies = GetFiles($"./src/**/bin/{configuration}/net45/*.Tests.dll");
XUnit2(testAssemblies, new XUnit2Settings {
Parallelism = ParallelismOption.All,
NoAppDomain = true
});
});

Task("TestCore")
.IsDependentOn("Build")
.Does(() =>
Expand Down
19 changes: 10 additions & 9 deletions src/Slack.Webhooks.Tests/ActionsBlockFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Blocks;
using Slack.Webhooks.Elements;
using Slack.Webhooks.Interfaces;
Expand All @@ -13,22 +14,22 @@ public class ActionsBlockFixtures
public void ShouldSerializeActionElements()
{
// arrange
var elementList = new List<IActionElement>
{
new Button(),
new SelectChannels(),
new SelectConversations(),
new SelectExternal(),
new SelectStatic(),
var elementList = new List<IActionElement>
{
new Button(),
new SelectChannels(),
new SelectConversations(),
new SelectExternal(),
new SelectStatic(),
new SelectUsers(),
new Overflow(),
new DatePicker()
};
var actions = new Actions { Elements = elementList };

// act
var elementListPayload = SlackClient.SerializeObject(elementList);
var payload = SlackClient.SerializeObject(actions);
var elementListPayload = ApiBase.SerializeObject(elementList);
var payload = ApiBase.SerializeObject(actions);

// assert
payload.Should().Contain($"\"elements\":{elementListPayload}");
Expand Down
3 changes: 2 additions & 1 deletion src/Slack.Webhooks.Tests/BlockFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using FluentAssertions;
using Newtonsoft.Json;
using Slack.Webhooks.Api;
using Slack.Webhooks.Blocks;
using Xunit;

Expand All @@ -13,7 +14,7 @@ public class BlockFixtures
public void ShouldHaveBlockTypeAndBlockId(Block block, string expectedType, string expectedBlockId)
{
// arrange/act
var payload = SlackClient.SerializeObject(block);
var payload = ApiBase.SerializeObject(block);

// assert
payload.Should().Contain($"\"type\":\"{expectedType}\"");
Expand Down
19 changes: 10 additions & 9 deletions src/Slack.Webhooks.Tests/ButtonElementFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Elements;
using Xunit;

Expand All @@ -13,7 +14,7 @@ public void ShouldSerializeType()
var button = new Button();

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"type\":\"button\"");
Expand All @@ -23,10 +24,10 @@ public void ShouldSerializeType()
public void ShouldSerializeText()
{
// arrange
var button = new Button { Text = new TextObject { Text = "Test Text" }};
var button = new Button { Text = new TextObject { Text = "Test Text" } };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"text\":{\"type\":\"plain_text\"");
Expand All @@ -39,7 +40,7 @@ public void ShouldSerializeActionId()
var button = new Button { ActionId = "Action123" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"action_id\":\"Action123\"");
Expand All @@ -52,7 +53,7 @@ public void ShouldSerializeUrl()
var button = new Button { Url = "http://someurl.com" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"url\":\"http://someurl.com\"");
Expand All @@ -65,7 +66,7 @@ public void ShouldSerializeValue()
var button = new Button { Value = "Value123" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"value\":\"Value123\"");
Expand All @@ -78,7 +79,7 @@ public void ShouldSerializeStyle()
var button = new Button { Style = "Style123" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"style\":\"Style123\"");
Expand All @@ -92,8 +93,8 @@ public void ShouldSerializeConfirm()
var button = new Button { Confirm = confirm };

// act
var confirmPayload = SlackClient.SerializeObject(confirm);
var payload = SlackClient.SerializeObject(button);
var confirmPayload = ApiBase.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain($"\"confirm\":{confirmPayload}");
Expand Down
17 changes: 9 additions & 8 deletions src/Slack.Webhooks.Tests/ConfirmationElementFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Elements;
using Xunit;

Expand All @@ -10,10 +11,10 @@ public class ConfirmationElementFixtures
public void ShouldSerializeTitle()
{
// arrange
var confirm = new Confirmation { Title = new TextObject { Text = "Title Test"} };
var confirm = new Confirmation { Title = new TextObject { Text = "Title Test" } };

// act
var payload = SlackClient.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(confirm);

// assert
payload.Should().Contain("\"title\":{");
Expand All @@ -24,10 +25,10 @@ public void ShouldSerializeTitle()
public void ShouldSerializeText()
{
// arrange
var confirm = new Confirmation { Text = new TextObject { Text = "Title Test"} };
var confirm = new Confirmation { Text = new TextObject { Text = "Title Test" } };

// act
var payload = SlackClient.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(confirm);

// assert
payload.Should().Contain("\"text\":{");
Expand All @@ -38,10 +39,10 @@ public void ShouldSerializeText()
public void ShouldSerializeConfirm()
{
// arrange
var confirm = new Confirmation { Confirm = new TextObject { Text = "Title Test"} };
var confirm = new Confirmation { Confirm = new TextObject { Text = "Title Test" } };

// act
var payload = SlackClient.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(confirm);

// assert
payload.Should().Contain("\"confirm\":{");
Expand All @@ -52,10 +53,10 @@ public void ShouldSerializeConfirm()
public void ShouldSerializeDeny()
{
// arrange
var confirm = new Confirmation { Deny = new TextObject { Text = "Title Test"} };
var confirm = new Confirmation { Deny = new TextObject { Text = "Title Test" } };

// act
var payload = SlackClient.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(confirm);

// assert
payload.Should().Contain("\"deny\":{");
Expand Down
7 changes: 4 additions & 3 deletions src/Slack.Webhooks.Tests/ContextBlockFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Blocks;
using Slack.Webhooks.Elements;
using Slack.Webhooks.Interfaces;
Expand All @@ -19,7 +20,7 @@ public void ShouldBeAbleToContainImageElements()
};

// act
var payload = SlackClient.SerializeObject(context);
var payload = ApiBase.SerializeObject(context);

// assert
payload.Should().Contain("\"elements\":["); // bleeugh
Expand All @@ -29,13 +30,13 @@ public void ShouldBeAbleToContainImageElements()
public void ShouldBeAbleToContainTextElements()
{
// arrange
var context = new Context
var context = new Context
{
Elements = new List<IContextElement>() { new TextObject() }
};

// act
var payload = SlackClient.SerializeObject(context);
var payload = ApiBase.SerializeObject(context);

// assert
payload.Should().Contain("\"elements\":["); // bleeugh
Expand Down
15 changes: 8 additions & 7 deletions src/Slack.Webhooks.Tests/DatePickerElementFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Elements;
using Xunit;

Expand All @@ -13,7 +14,7 @@ public void ShouldSerializeType()
var button = new DatePicker();

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"type\":\"datepicker\"");
Expand All @@ -26,7 +27,7 @@ public void ShouldSerializeActionId()
var button = new DatePicker { ActionId = "Action123" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"action_id\":\"Action123\"");
Expand All @@ -39,7 +40,7 @@ public void ShouldSerializeInitialDate()
var button = new DatePicker { InitialDate = "2019-11-01" };

// act
var payload = SlackClient.SerializeObject(button);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain("\"initial_date\":\"2019-11-01\"");
Expand All @@ -53,8 +54,8 @@ public void ShouldSerializePlaceholder()
var button = new DatePicker { Placeholder = text };

// act
var textPayload = SlackClient.SerializeObject(text);
var payload = SlackClient.SerializeObject(button);
var textPayload = ApiBase.SerializeObject(text);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain($"\"placeholder\":{textPayload}");
Expand All @@ -68,8 +69,8 @@ public void ShouldSerializeConfirm()
var button = new DatePicker { Confirm = confirm };

// act
var confirmPayload = SlackClient.SerializeObject(confirm);
var payload = SlackClient.SerializeObject(button);
var confirmPayload = ApiBase.SerializeObject(confirm);
var payload = ApiBase.SerializeObject(button);

// assert
payload.Should().Contain($"\"confirm\":{confirmPayload}");
Expand Down
3 changes: 2 additions & 1 deletion src/Slack.Webhooks.Tests/ElementFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using FluentAssertions;
using Slack.Webhooks.Api;
using Xunit;

namespace Slack.Webhooks.Tests
Expand All @@ -11,7 +12,7 @@ public class ElementFixtures
public void ShouldHaveBlockTypeAndBlockId(Elements.Element element, string expectedType)
{
// arrange/act
var payload = SlackClient.SerializeObject(element);
var payload = ApiBase.SerializeObject(element);

// assert
payload.Should().Contain($"\"type\":\"{expectedType}\"");
Expand Down
7 changes: 4 additions & 3 deletions src/Slack.Webhooks.Tests/FileBlockFixtures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using Slack.Webhooks.Api;
using Slack.Webhooks.Blocks;
using Xunit;

Expand All @@ -10,10 +11,10 @@ public class FileBlockFixtures
public void ShouldHaveExternalId()
{
// arrange
var file = new File { ExternalId = "AB_1234"};
var file = new File { ExternalId = "AB_1234" };

// act
var payload = SlackClient.SerializeObject(file);
var payload = ApiBase.SerializeObject(file);

// assert
payload.Should().Contain("\"external_id\":\"AB_1234\"");
Expand All @@ -26,7 +27,7 @@ public void ShouldHaveRemoteSourceByDefault()
var file = new File();

// act
var payload = SlackClient.SerializeObject(file);
var payload = ApiBase.SerializeObject(file);

// assert
file.Source.Should().Be("remote");
Expand Down
Loading