Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add database test #125

Merged
merged 9 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private static void GenerateEntity(SourceProductionContext context, string solut
var code = new CodeBuilder($"{entity.Name}.g.cs", context);

code.AppendLine($"using Nox.Types;");
code.AppendLine($"using System;");
code.AppendLine($"using System.Collections.Generic;");
code.AppendLine();
code.AppendLine($"namespace {solutionNameSpace}.Domain;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Generate(SourceProductionContext context, string solutionName
code.AppendLine(@"using Microsoft.EntityFrameworkCore;");
code.AppendLine(@"using Nox.Solution;");
code.AppendLine(@"using Nox.Types.EntityFramework.vNext;");
code.AppendLine(@"using SampleWebApp.Domain;");
code.AppendLine($@"using {solutionNameSpace}.Domain;");
code.AppendLine();
code.AppendLine($"namespace {solutionNameSpace}.Infrastructure.Persistence;");
code.AppendLine();
Expand Down Expand Up @@ -83,8 +83,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}

base.OnModelCreating(modelBuilder);
}

ILoveMyTortoise marked this conversation as resolved.
Show resolved Hide resolved
base.OnModelCreating(modelBuilder);
}
}
");
Expand Down
4 changes: 2 additions & 2 deletions src/SampleWebApp/Examples/SampleWebAppDbContextExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
_databaseConfigurator.ConfigureEntity(modelBuilder.Entity(type), entity);
}
}

base.OnModelCreating(modelBuilder);
}

base.OnModelCreating(modelBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable

using Nox.Types;
using System;
using System.Collections.Generic;

namespace SampleWebApp.Domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable

using Nox.Types;
using System;
using System.Collections.Generic;

namespace SampleWebApp.Domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable

using Nox.Types;
using System;
using System.Collections.Generic;

namespace SampleWebApp.Domain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}

base.OnModelCreating(modelBuilder);
}

base.OnModelCreating(modelBuilder);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable

using Nox.Types;
using System;
using System.Collections.Generic;

namespace SampleWebApp.Domain;
Expand Down
237 changes: 237 additions & 0 deletions tests/Nox.Generator.Tests/Database/Design/test.solution.nox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
#
# workplace.solution.nox.yaml
#
# yaml-language-server: $schema=https://noxorg.dev/schemas/solution.json
#

name: TestDatabaseWebApp

description: Sample Nox solution yaml configuration

variables:
DATABASE_PROVIDER: slqServer
DATABASE_SERVER: localhost
DATABASE_USER: sa
DATABASE_PASSWORD: Developer*123
DATABASE_PORT: "5432"

environments:

- name: dev
description: Used for development and testing

- name: test
description: Test environment

- name: uat
description: For them end users to check it works

- name: prod
description: Production environment used for, well - the real thing!
isProduction: true

versionControl:
provider: azureDevops
host: https://dev.azure.com/iwgplc
folders:
sourceCode: /src
containers: /docker

team:

- name: Andre Sharpe
userName: andre.sharpe@iwgplc.com
roles: [architect, owner, administrator, developer, manager]

- name: Jan Schutte
userName: jan.schutte@iwgplc.com
roles: [architect, administrator, developer, devOpsEngineer]

- name: Anton Du Plessis
userName: anton.duplessis@iwgplc.com
roles: [projectManager]

- name: Morne Van Zyl
userName: morne.vanzyl@iwgplc.com
roles: [technicalWriter]

- name: Dmytro Dorodnykh
userName: dmytro.dorodnykh@iwgplc.com
roles: [developer]

- name: Oleksandr Vlasenko
userName: oleksandr.vlasenko@regus.com
roles: [architect, developer]

domain:

entities:

- name: TestEntity
description: Entity created for testing database

userInterface:
icon: world

persistence:
isVersioned: true
tableName: TestEntity
schema: dbo
create:
isEnabled: true
raiseEvents: true
read:
isEnabled: true
update:
isEnabled: true
raiseEvents: true
delete:
isEnabled: true
raiseEvents: true
useSoftDelete: true

keys:

- name: Id
type: text
textTypeOptions:
isUnicode: false
minLength: 2
maxLength: 2

attributes:

- name: TextTestField
type: text
textTypeOptions:
minLength: 4
maxLength: 63
isRequired: true

- name: NumberTestField
type: number
numberTypeOptions:
minValue: 4
maxValue: 894
isRequired: true

- name: MoneyTestField
type: money

#- name: CountryCode2TestField
# type: countryCode2

#- name: GeoCoordTestField
# type: latLong

#- name: AreaTestField
# type: area

#- name: BooleanTestField
# type: boolean

#- name: CountryCode3TestField
# type: countryCode3

#- name: CountryNumberTestField
# type: countryNumber

#- name: CurrencyCodeTestField
# type: currencyCode

#- name: CurrencyNumberTestField
# type: currencyNumber

#- name: DateTimeTestField
# type: dateTime

#- name: DateTimeRangeTestField
# type: dateTimeRange

#- name: DistanceTestField
# type: distance

#- name: EmailTestField
# type: email

#- name: EncryptedTextTestField
# type: encryptedText

#- name: GuidTestField
# type: guid

#- name: HashedTextTestField
# type: hashedText

#- name: InternetDomainTestField
# type: internetDomain

#- name: IpAddressTestField
# type: ipAddress

#- name: LengthTestField
# type: length

#- name: MacAddressTestField
# type: macAddress

#- name: MonthTestField
# type: month

#- name: NuidTestField
# type: nuid

#- name: PasswordTestField
# type: password

#- name: PercentageTestField
# type: percentage

#- name: PhoneNumberTestField
# type: phoneNumber

#- name: StreetAddressTestField
# type: streetAddress

#- name: TempratureTestField
# type: temperature

#- name: UriTestField
# type: uri

#- name: VolumeTestField
# type: volume

#- name: WeightTestField
# type: weight

#- name: YearTestField
# type: year

#- name: CultureCodeTestField
# type: cultureCode

#- name: LanguageCodeTestField
# type: languageCode

infrastructure:

persistence:
databaseServer:
name: SampleCurrencyDb

# Sql Server
serverUri: sqlserver.iwgplc.com
provider: sqlServer
port: 1433
user: sqluser
password: sqlpassword

messaging:
integrationEventServer:
name: IntegrationBus
provider: rabbitMq
serverUri: rabbitmq://localhost
port: 5672
user: guest
password: guest
40 changes: 40 additions & 0 deletions tests/Nox.Generator.Tests/Database/Models/AuditableEntityBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Generated

#nullable enable

using System;

namespace TestDatabaseWebApp.Domain;

public partial class AuditableEntityBase
{
/// <summary>
/// The date and time when this entity was first created (in Coordinated Universal Time).
/// </summary>
public DateTime CreatedAtUtc { get; set; }

/// <summary>
/// The user that created the entity.
/// </summary>
public string? CreatedBy { get; set; }

/// <summary>
/// The date and time when this entity was last updated (in Coordinated Universal Time).
/// </summary>
public DateTime? UpdatedAtUtc { get; set; }

/// <summary>
/// The user that last updated the entity.
/// </summary>
public string? UpdatedBy { get; set; }

/// <summary>
/// The date and time when this entity was deleted (in Coordinated Universal Time).
/// </summary>
public DateTime? DeletedAtUtc { get; set; }

/// <summary>
/// The user that deleted the entity.
/// </summary>
public string? DeletedBy { get; set; }
}
Loading