dev.azure.com/aidainnovazione0090/DeviceManager/_git/go-mod-core-contracts@v1.0.2/dtos/responses/application_test.go (about) 1 package responses_test 2 3 import ( 4 "testing" 5 6 "dev.azure.com/aidainnovazione0090/DeviceManager/_git/go-mod-core-contracts/dtos" 7 "dev.azure.com/aidainnovazione0090/DeviceManager/_git/go-mod-core-contracts/dtos/common" 8 "dev.azure.com/aidainnovazione0090/DeviceManager/_git/go-mod-core-contracts/dtos/responses" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestNewApplicationResponse(t *testing.T) { 13 requestID := "123" 14 message := "Test message" 15 statusCode := 200 16 device := dtos.Device{ 17 Name: "Test Device", 18 Id: "1", 19 } 20 21 application := dtos.Application{ 22 Id: "1", 23 Name: "Test Application", 24 Devices: []dtos.Device{device}, 25 } 26 27 expectedResponse := responses.ApplicationResponse{ 28 BaseResponse: common.NewBaseResponse(requestID, message, statusCode), 29 Application: application, 30 } 31 32 actualResponse := responses.NewApplicationResponse(requestID, message, statusCode, application) 33 34 assert.Equal(t, expectedResponse, actualResponse) 35 } 36 func TestNewMultiApplicationsResponse(t *testing.T) { 37 requestID := "123" 38 message := "Test message" 39 statusCode := 200 40 totalCount := uint32(5) 41 applications := []dtos.Application{ 42 {Id: "1", Name: "App 1"}, 43 {Id: "2", Name: "App 2"}, 44 {Id: "3", Name: "App 3"}, 45 } 46 47 expectedResponse := responses.MultiApplicationsResponse{ 48 BaseWithTotalCountResponse: common.NewBaseWithTotalCountResponse(requestID, message, statusCode, totalCount), 49 Applications: applications, 50 } 51 52 actualResponse := responses.NewMultiApplicationResponse(requestID, message, statusCode, totalCount, applications) 53 54 assert.Equal(t, expectedResponse, actualResponse) 55 }